Disclaimer: I'm not an expert. If the solution is obvious to you, that's awesome! Hopefully it will be ovious to me too someday.
I have created a class Trigger() for triggering events based on one or more rules. Each instance has a method to evaluate if the rules are currently met. For example, if there is only one rule, "Wednesday 0800-1400" and it is currently Wednesday between those times, then the trigger returns True.
Overlapping triggers are not allowed (see example below)
TriggerOne = { day: "Monday", start: "08:00", end: "14:00" }
TriggerTwo = { day: "Monday", start: "12:00", end:"16:00" }
To test overlapping triggers I implemented a self.eq() that returns True if time frames or other rules overlap between triggers, and False if the rule(s) do not overlap.
HELP! I started writing a custom class to manage the triggers, but I was hoping there might be a way to make my trigger instances hashable based on their rules so that I can add them to a set()
I read this question, for which an answer states that equivalent instances should hash to the same thing: Making a python user-defined class sortable, hashable
How could I (if it's possible) go about writing a self.hash() that could accomplish this?
I really appreciate constructive feedback and ideas