Class: Schedule::Period
- Defined in:
- lib/abstractivator/schedule/schedule.rb
Instance Attribute Summary collapse
-
#start ⇒ Object
inclusive.
-
#stop ⇒ Object
exclusive.
Instance Method Summary collapse
- #includes?(localtime) ⇒ Boolean
-
#initialize(start, stop) ⇒ Period
constructor
A new instance of Period.
- #to_clock(wmin) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(start, stop) ⇒ Period
Returns a new instance of Period.
53 54 55 56 |
# File 'lib/abstractivator/schedule/schedule.rb', line 53 def initialize(start, stop) @start = start @stop = stop end |
Instance Attribute Details
#start ⇒ Object
inclusive
50 51 52 |
# File 'lib/abstractivator/schedule/schedule.rb', line 50 def start @start end |
#stop ⇒ Object
exclusive
51 52 53 |
# File 'lib/abstractivator/schedule/schedule.rb', line 51 def stop @stop end |
Instance Method Details
#includes?(localtime) ⇒ Boolean
58 59 60 61 62 63 64 |
# File 'lib/abstractivator/schedule/schedule.rb', line 58 def includes?(localtime) wmin = Wmin.from_localtime(localtime) result = start <= wmin && wmin < stop #puts "#{to_s} includes? #{to_clock(wmin)} (#{localtime}) : #{result}" #puts " #{start} <= #{wmin} && #{wmin} < #{stop}" result end |
#to_clock(wmin) ⇒ Object
70 71 72 73 74 |
# File 'lib/abstractivator/schedule/schedule.rb', line 70 def to_clock(wmin) day = (wmin / Wmin::DAY) % 7 minutes = wmin % Wmin::DAY "#{minutes / 60}:#{minutes % 60}#{WEEKDAYS[day]}" end |
#to_s ⇒ Object
66 67 68 |
# File 'lib/abstractivator/schedule/schedule.rb', line 66 def to_s "#{to_clock(start)}-#{to_clock(stop)}" end |