Class: Wristwatch::Schedule
- Inherits:
-
Object
- Object
- Wristwatch::Schedule
- Includes:
- Enumerable, Intervals
- Defined in:
- lib/wristwatch/schedule.rb
Instance Attribute Summary collapse
-
#now ⇒ Object
readonly
Returns the value of attribute now.
Instance Method Summary collapse
- #available_intervals ⇒ Object
- #each ⇒ Object
-
#initialize(time = Time.now) ⇒ Schedule
constructor
A new instance of Schedule.
- #intervals ⇒ Object
- #method_missing(meth, *args, &blk) ⇒ Object
Methods included from Intervals
#annually, #bi_daily, #bi_hourly, #bi_monthly, #bi_weekly, #daily, #hourly, #monthly, #quarter_hourly, #quarterly, #semiannually, #weekly
Constructor Details
#initialize(time = Time.now) ⇒ Schedule
Returns a new instance of Schedule.
8 9 10 |
# File 'lib/wristwatch/schedule.rb', line 8 def initialize(time = Time.now) @now = time end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wristwatch/schedule.rb', line 26 def method_missing(meth, *args, &blk) if meth.to_s[meth.to_s.length - 1, 1] === "?" begin send(meth[0, meth.to_s.length - 1], *args, &blk) rescue NoMethodError super(meth, *args, &blk) end else super(meth, *args, &blk) end end |
Instance Attribute Details
#now ⇒ Object (readonly)
Returns the value of attribute now.
6 7 8 |
# File 'lib/wristwatch/schedule.rb', line 6 def now @now end |
Instance Method Details
#available_intervals ⇒ Object
16 17 18 |
# File 'lib/wristwatch/schedule.rb', line 16 def available_intervals Intervals.instance_methods end |
#each ⇒ Object
20 21 22 23 24 |
# File 'lib/wristwatch/schedule.rb', line 20 def each intervals.each do |interval| yield interval end end |
#intervals ⇒ Object
12 13 14 |
# File 'lib/wristwatch/schedule.rb', line 12 def intervals available_intervals.select { |interval| send(interval) } end |