Class: RubbishCollection::Schedule
- Inherits:
-
Object
- Object
- RubbishCollection::Schedule
- Defined in:
- lib/rubbish_collection.rb
Instance Attribute Summary collapse
-
#resolution ⇒ Object
readonly
Returns the value of attribute resolution.
Class Method Summary collapse
Instance Method Summary collapse
- #add_rule(rule) ⇒ Object
- #include?(time) ⇒ Boolean
-
#initialize(resolution) ⇒ Schedule
constructor
A new instance of Schedule.
- #to_s ⇒ Object
Constructor Details
#initialize(resolution) ⇒ Schedule
Returns a new instance of Schedule.
92 93 94 |
# File 'lib/rubbish_collection.rb', line 92 def initialize resolution self.resolution = resolution end |
Instance Attribute Details
#resolution ⇒ Object
Returns the value of attribute resolution.
89 90 91 |
# File 'lib/rubbish_collection.rb', line 89 def resolution @resolution end |
Class Method Details
.day_of_week(day_name) ⇒ Object
96 97 98 99 100 |
# File 'lib/rubbish_collection.rb', line 96 def self.day_of_week day_name normalised_name = day_name[0,1].upcase + day_name[1..-1].downcase day_const = Runt.const_get normalised_name Runt::DIWeek.new day_const end |
.hour(hour) ⇒ Object
102 103 104 |
# File 'lib/rubbish_collection.rb', line 102 def self.hour hour Runt::REDay.new hour, 0, hour, 59, true end |
Instance Method Details
#add_rule(rule) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/rubbish_collection.rb', line 106 def add_rule rule if condition.nil? self.condition = rule return end self.condition = condition & rule end |
#include?(time) ⇒ Boolean
114 115 116 117 |
# File 'lib/rubbish_collection.rb', line 114 def include? time time_with_resolution = resolution.match_resolution time condition.include? time_with_resolution end |
#to_s ⇒ Object
119 120 121 |
# File 'lib/rubbish_collection.rb', line 119 def to_s condition.to_s end |