Class: SimplePvr::Model::Channel
- Inherits:
-
Object
- Object
- SimplePvr::Model::Channel
- Includes:
- DataMapper::Resource
- Defined in:
- lib/simple_pvr/model/channel.rb
Class Method Summary collapse
- .add(name, frequency, id) ⇒ Object
- .all_with_current_programmes ⇒ Object
- .clear ⇒ Object
- .with_current_programmes(id) ⇒ Object
- .with_name(name) ⇒ Object
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_programmes ⇒ Object
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 |
.clear ⇒ Object
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 |