Class: NetworkExecutive::Channel

Inherits:
EventMachine::Channel
  • Object
show all
Includes:
Scheduling
Defined in:
app/models/network_executive/channel.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Scheduling

#schedule, #whats_on?, #whats_on_at?, #whats_on_between?

Class Method Details

.find_by_name(name) ⇒ Object

TODO: Is this the right place for this?



39
40
41
42
43
# File 'app/models/network_executive/channel.rb', line 39

def find_by_name( name )
  Network.channels.find do |c|
    c.name == name
  end
end

.inherited(klass) ⇒ Object



34
35
36
# File 'app/models/network_executive/channel.rb', line 34

def inherited( klass )
  Network.channels << klass.new
end

Instance Method Details

#display_nameObject



13
14
15
# File 'app/models/network_executive/channel.rb', line 13

def display_name
  name.gsub %r{_}, ' '
end

#nameObject Also known as: to_s



8
9
10
# File 'app/models/network_executive/channel.rb', line 8

def name
  self.class.name.demodulize.underscore
end

#play(program) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/network_executive/channel.rb', line 17

def play( program )
  if program.occurs_at?( Time.now.change(sec:0) )
    program.play do |msg|
      push msg
    end
  else
    program.update do |msg|
      push msg
    end
  end
end

#play_whats_on(&block) ⇒ Object



29
30
31
# File 'app/models/network_executive/channel.rb', line 29

def play_whats_on( &block )
  whats_on?.play( &block )
end