Class: SimplePvr::Model::Channel

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/simple_pvr/model/channel.rb

Class Method Summary collapse

Class Method Details

.add(name, frequency, id) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/simple_pvr/model/channel.rb', line 16

def self.add(name, frequency, id)
  self.create(
    name: name,
    frequency: frequency,
    channel_id: id
  )
end

.all_with_current_programmesObject



28
29
30
31
# File 'lib/simple_pvr/model/channel.rb', line 28

def self.all_with_current_programmes
  now = Time.now
  self.all(order: :name).map {|channel| decorated_with_current_programmes(channel, now) }
end

.clearObject



33
34
35
36
# File 'lib/simple_pvr/model/channel.rb', line 33

def self.clear
  Programme.destroy
  self.destroy
end

.with_current_programmes(id) ⇒ Object



24
25
26
# File 'lib/simple_pvr/model/channel.rb', line 24

def self.with_current_programmes(id)
  decorated_with_current_programmes(get(id), Time.now)
end

.with_name(name) ⇒ Object



38
39
40
41
42
# File 'lib/simple_pvr/model/channel.rb', line 38

def self.with_name(name)
  result = self.first(name: name)
  raise "Unknown channel: '#{name}'" unless result
  result
end