Class: Poms::Broadcast

Inherits:
Poms::Builder::NestedOpenStruct show all
Includes:
HasAncestors, HasBaseAttributes
Defined in:
lib/poms/broadcast.rb

Direct Known Subclasses

Strand

Instance Method Summary collapse

Methods included from HasBaseAttributes

#description, #title

Methods included from HasAncestors

included

Methods included from Base

#rev

Constructor Details

#initialize(hash) ⇒ Broadcast

Returns a new instance of Broadcast.



10
11
12
13
# File 'lib/poms/broadcast.rb', line 10

def initialize hash
  super
  process_schedule_events
end

Instance Method Details

#available_untilObject



35
36
37
38
39
# File 'lib/poms/broadcast.rb', line 35

def available_until
  return nil if locations.nil? or locations.empty?
  timestamp = locations.map(&:publish_stop).compact.first
  return Time.at(timestamp / 1000).to_datetime if timestamp
end

#odi_streamsObject



26
27
28
29
30
31
32
33
# File 'lib/poms/broadcast.rb', line 26

def odi_streams
  return [] if locations.nil? or locations.empty?
  odi_streams = locations.select { |l| l.program_url.match(/^odi/) }
  streams = odi_streams.map do |l|
    l.program_url.match(/^[\w+]+\:\/\/[\w\.]+\/video\/(\w+)\/\w+/)[1]
  end
  streams.uniq
end

#process_schedule_eventsObject



15
16
17
18
19
20
# File 'lib/poms/broadcast.rb', line 15

def process_schedule_events
  if schedule_events
    schedule_events.select! { |e| e.channel.match Poms::VALID_CHANNELS }
  end
  self.schedule_events = schedule_events.map { |e| Poms::ScheduleEvent.new e.marshal_dump } if schedule_events
end

#series_midObject



22
23
24
# File 'lib/poms/broadcast.rb', line 22

def series_mid
  serie.try :mid_ref || serie.mid
end