Class: IceT::Schedule
- Inherits:
-
Object
- Object
- IceT::Schedule
- Extended by:
- Forwardable
- Includes:
- Conversions::Schedule
- Defined in:
- lib/ice_t/schedule.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Schedule
constructor
A new instance of Schedule.
- #occurrences ⇒ Object
Methods included from Conversions::Schedule
Constructor Details
#initialize(opts = {}) ⇒ Schedule
Returns a new instance of Schedule.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ice_t/schedule.rb', line 39 def initialize(opts={}) opts = { start_time: nil, end_time: nil }.merge(opts) @start_time = opts[:start_time] @end_time = opts[:end_time] @rules = IceT::Rule::Repository.new end |
Instance Attribute Details
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
37 38 39 |
# File 'lib/ice_t/schedule.rb', line 37 def end_time @end_time end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
36 37 38 |
# File 'lib/ice_t/schedule.rb', line 36 def start_time @start_time end |
Instance Method Details
#occurrences ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ice_t/schedule.rb', line 50 def occurrences return [] if @rules.empty? # TODO: better error message fail('this needs start_time and end_time') if @start_time.nil? && @end_time.nil? @rules.collect{ |rule| rule.occurrences(@start_time, @end_time) }.flatten end |