Class: NetworkExecutive::ProgramScheduleProxy
- Inherits:
-
Object
- Object
- NetworkExecutive::ProgramScheduleProxy
- Defined in:
- lib/network_executive/program_schedule_proxy.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize(start_time = nil, duration = nil, &block) ⇒ ProgramScheduleProxy
constructor
A new instance of ProgramScheduleProxy.
- #method_missing(method_id, *args) ⇒ Object
- #respond_to_missing?(method_id, include_private = false) ⇒ Boolean
- #to_schedule ⇒ Object
Constructor Details
#initialize(start_time = nil, duration = nil, &block) ⇒ ProgramScheduleProxy
Returns a new instance of ProgramScheduleProxy.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/network_executive/program_schedule_proxy.rb', line 13 def initialize( start_time = nil, duration = nil, &block ) start_time ||= Time.now.beginning_of_day duration ||= 24.hours @start_time, @duration = start_time, duration @schedule = IceCube::Schedule.new( start_time, duration:duration.to_i ) if block_given? @parsing_schedule = true instance_eval( &block ) @parsing_schedule = false end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/network_executive/program_schedule_proxy.rb', line 42 def method_missing( method_id, *args ) if @parsing_schedule && IceCube::Rule.respond_to?( method_id ) IceCube::Rule.send( method_id, *args ).tap do |rule| @schedule.add_recurrence_rule rule end elsif @schedule.respond_to?( method_id ) @schedule.send( method_id, *args ) else super end end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
11 12 13 |
# File 'lib/network_executive/program_schedule_proxy.rb', line 11 def duration @duration end |
#start_time ⇒ Object
Returns the value of attribute start_time.
11 12 13 |
# File 'lib/network_executive/program_schedule_proxy.rb', line 11 def start_time @start_time end |
Instance Method Details
#respond_to_missing?(method_id, include_private = false) ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/network_executive/program_schedule_proxy.rb', line 34 def respond_to_missing?( method_id, include_private = false ) if @parsing_schedule IceCube::Rule.respond_to?( method_id ) || super else @schedule.respond_to?( method_id ) || super end end |
#to_schedule ⇒ Object
30 31 32 |
# File 'lib/network_executive/program_schedule_proxy.rb', line 30 def to_schedule @schedule end |