Class: Event::Timed
Constant Summary
Constants inherited from Event
HOUR_DIVISORS, MINUTE_DIVISORS, SECOND_DIVISORS
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Attributes inherited from Event
#count, #next, #previous, #scheduler, #start, #stop, #times
Instance Method Summary collapse
- #hours ⇒ Object
-
#initialize(hours = [0], minutes = [0], seconds = [0], options = {}, &block) ⇒ Timed
constructor
A new instance of Timed.
-
#inspect ⇒ Object
A string representation.
- #minutes ⇒ Object
- #seconds ⇒ Object
Methods inherited from Event
#<=>, #alter, at, #call, #due?, every, #extract_time_range, #finished, #finished?, #join, #off, #off?, #on, #on?, #one_done, #reschedule, #seconds_left, timed, #times_left, #to_f, #to_i, #update_scheduler
Constructor Details
#initialize(hours = [0], minutes = [0], seconds = [0], options = {}, &block) ⇒ Timed
Returns a new instance of Timed.
41 42 43 44 45 46 47 48 49 |
# File 'lib/event/timed.rb', line 41 def initialize(hours=[0], minutes=[0], seconds=[0], ={}, &block) super(, &block) @original = [hours.inspect, minutes.inspect, seconds.inspect] @indices = [0,0,0] @hours = extract_time_range(hours, 23, HOUR_DIVISORS).sort @minutes = extract_time_range(minutes, 59, MINUTE_DIVISORS).sort @seconds = extract_time_range(seconds, 59, SECOND_DIVISORS).sort @next = calculate_first(@start) end |
Instance Attribute Details
#original ⇒ Object (readonly)
Returns the value of attribute original.
19 20 21 |
# File 'lib/event/timed.rb', line 19 def original @original end |
Instance Method Details
#hours ⇒ Object
51 52 53 |
# File 'lib/event/timed.rb', line 51 def hours @hours.dup end |
#inspect ⇒ Object
A string representation. Just nice for printing.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/event/timed.rb', line 22 def inspect string = if off? then "Off" elsif finished? then "Finished" elsif left = seconds_left then "Due: %s (%.2fs)" % [@next.strftime("%H:%M:%S"), left] else "Error" end "#<%s %s, %s done, timed for %s, %s, %s>" % [ self.class, string, @times ? "#{@count}/#{@times}" : @count, *@original ] end |
#minutes ⇒ Object
55 56 57 |
# File 'lib/event/timed.rb', line 55 def minutes @minutes.dup end |
#seconds ⇒ Object
59 60 61 |
# File 'lib/event/timed.rb', line 59 def seconds @seconds.dup end |