Class: NetworkExecutive::ScheduledProgram

Inherits:
Object
  • Object
show all
Defined in:
lib/network_executive/scheduled_program.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ScheduledProgram

Returns a new instance of ScheduledProgram.



5
6
7
# File 'lib/network_executive/scheduled_program.rb', line 5

def initialize( *args )
  @program, @occurrence, @remainder, @portion = *args
end

Instance Attribute Details

#occurrenceObject

Returns the value of attribute occurrence.



3
4
5
# File 'lib/network_executive/scheduled_program.rb', line 3

def occurrence
  @occurrence
end

#portionObject

Returns the value of attribute portion.



3
4
5
# File 'lib/network_executive/scheduled_program.rb', line 3

def portion
  @portion
end

#programObject

Returns the value of attribute program.



3
4
5
# File 'lib/network_executive/scheduled_program.rb', line 3

def program
  @program
end

#remainderObject

Returns the value of attribute remainder.



3
4
5
# File 'lib/network_executive/scheduled_program.rb', line 3

def remainder
  @remainder
end

Instance Method Details

#+(other_program) ⇒ Object

Extends this scheduled program with another program of the same type.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/network_executive/scheduled_program.rb', line 14

def +( other_program )
  raise ArgumentError if @program.class != other_program.class

  additional_duration = other_program.duration + 1

  program.duration    += additional_duration
  occurrence.duration += additional_duration
  occurrence.end_time += additional_duration

  self
end

#display_nameObject



9
10
11
# File 'lib/network_executive/scheduled_program.rb', line 9

def display_name
  program.display_name
end