Class: Event::At
Constant Summary
Constants inherited from Event
HOUR_DIVISORS, MINUTE_DIVISORS, SECOND_DIVISORS
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Attributes inherited from Event
#count, #next, #previous, #scheduler, #start, #stop, #times
Instance Method Summary collapse
-
#initialize(*datetimes, &block) ⇒ At
constructor
A new instance of At.
-
#inspect ⇒ Object
A string representation.
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(*datetimes, &block) ⇒ At
Returns a new instance of At.
43 44 45 46 47 48 49 50 |
# File 'lib/event/at.rb', line 43 def initialize(*datetimes, &block) super(datetimes.last.kind_of?(Hash) ? datetimes.pop : {}, &block) @datetimes = datetimes.sort #@start = @datetimes.first #@stop = @datetimes.last @index = nil @next = calculate_first(@start) end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
19 20 21 |
# File 'lib/event/at.rb', line 19 def index @index end |
Instance Method Details
#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 40 41 |
# File 'lib/event/at.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 datetimes = (@previous ? @datetimes.select { |dt| dt > @previous } : @datetimes) "#<%s %s, %s done, due at %s%s>" % [ self.class, string, @times ? "#{@count}/#{@times}" : @count, datetimes.first(5).join(', '), datetimes.length > 5 ? "..." : "" ] end |