Class: EyeTV::Program

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

Overview

This class represents an instnace of schedule Program on EyeTV

Constant Summary collapse

@@repeats_possible =
[:never,:none,:daily,:weekdays,:weekends]
@@qualities_possible =
[:standard, :high]
@@input_sources_possible =
[:tuner_input, :composite_video_input, :S_video_input]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program_instance) ⇒ Program

Returns a new instance of Program.



10
11
12
# File 'lib/program.rb', line 10

def initialize(program_instance)
  @program_ref = program_instance      
end

Class Method Details

.input_sources_possibleObject



79
80
81
# File 'lib/program.rb', line 79

def self.input_sources_possible
  @@input_sources_possible
end

.qualities_possibleObject



105
106
107
# File 'lib/program.rb', line 105

def self.qualities_possible
  @@qualities_possible
end

.repeats_possibleObject



92
93
94
# File 'lib/program.rb', line 92

def self.repeats_possible
  @@repeats_possible
end

Instance Method Details

#channel_numberObject



66
67
68
# File 'lib/program.rb', line 66

def channel_number
  @program_ref.channel_number.get
end

#channel_number=(new_channel_number) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/program.rb', line 70

def channel_number=(new_channel_number)
  old_value = channel_number
  @program_ref.channel_number.set(new_channel_number.to_i)
  if(channel_number == 0)
    channel_number = old_value
    raise "unknow channel #{new_channel_number}"
  end
end

#conflict?(test_start_time, nduration) ⇒ Boolean

test if the parameters enter in conflict with a program instance

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
# File 'lib/program.rb', line 41

def conflict?(test_start_time, nduration)
  nend_time = test_start_time + nduration
  if nend_time < start_time or end_time < test_start_time
    conflict = false
  else
    conflict = true
  end
end

#deleteObject



126
127
128
# File 'lib/program.rb', line 126

def delete
  @program_ref.delete
end

#descriptionObject



58
59
60
# File 'lib/program.rb', line 58

def description
  @program_ref.description.get
end

#description=(new_description) ⇒ Object



62
63
64
# File 'lib/program.rb', line 62

def description=(new_description)
  @program_ref.description.set(new_description)
end

#durationObject



27
28
29
# File 'lib/program.rb', line 27

def duration
  @program_ref.duration.get
end

#duration=(new_duration) ⇒ Object



31
32
33
# File 'lib/program.rb', line 31

def duration=(new_duration)
  @program_ref.duration.set(new_duration)
end

#enabled(value) ⇒ Object



122
123
124
# File 'lib/program.rb', line 122

def enabled(value)
  @program_ref.enabled.set(value)
end

#enabled?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/program.rb', line 118

def enabled?
  @program_ref.enabled.get
end

#end_timeObject

calculate the end time of program



36
37
38
# File 'lib/program.rb', line 36

def end_time
  start_time + duration
end

#input_sourceObject



83
84
85
# File 'lib/program.rb', line 83

def input_source
  @program_ref.input_source.get
end

#input_source=(new_input_source) ⇒ Object



87
88
89
90
# File 'lib/program.rb', line 87

def input_source=(new_input_source)
  raise "bad value for input_source" if !new_input_source.respond_to?(:to_sym) or not @@input_sources_possible.include?(new_input_source.to_sym)
  @program_ref.input_source.set(new_input_source.to_sym)
end

#qualityObject



109
110
111
# File 'lib/program.rb', line 109

def quality
  @program_ref.quality.get
end

#quality=(new_quality) ⇒ Object



113
114
115
116
# File 'lib/program.rb', line 113

def quality=(new_quality)
  raise "bad value for quality" if !new_quality.respond_to?(:to_sym) or not @@qualities_possible.include?(new_quality.to_sym)
  @program_ref.quality.set(new_quality.to_sym)
end

#repeatsObject



96
97
98
# File 'lib/program.rb', line 96

def repeats
  @program_ref.repeats.get
end

#repeats=(new_repeats) ⇒ Object



100
101
102
103
# File 'lib/program.rb', line 100

def repeats=(new_repeats)
  raise "bad value for repeats" if !new_repeats.respond_to?(:to_sym) or not @@repeats_possible.include?(new_repeats.to_sym)
  @program_ref.repeats.set(new_repeats.to_sym)
end

#start_timeObject



18
19
20
# File 'lib/program.rb', line 18

def start_time
  @program_ref.start_time.get
end

#start_time=(new_start_time) ⇒ Object



22
23
24
25
# File 'lib/program.rb', line 22

def start_time=(new_start_time)
  raise "Must be an datetime objet" if not new_start_time.is_a?(Time)
  @program_ref.start_time.set(new_start_time)
end

#titleObject



50
51
52
# File 'lib/program.rb', line 50

def title
  @program_ref.title.get
end

#title=(new_title) ⇒ Object



54
55
56
# File 'lib/program.rb', line 54

def title=(new_title)
  @program_ref.title.set(new_title)
end

#to_sObject



130
131
132
133
# File 'lib/program.rb', line 130

def to_s
  self.title.concat("; start : ").concat(self.start_time.to_s).concat("; duration : ").
    concat(self.duration.to_s).concat("; on channel : ").concat(self.channel_number.to_s)
end

#uidObject



14
15
16
# File 'lib/program.rb', line 14

def uid
  @program_ref.unique_ID.get
end