class TSparser::EventInformationSection

Public Class Methods

section_length_enough?(section_binary) click to toggle source
# File lib/definition/event_information_section.rb, line 5
def self.section_length_enough?(section_binary)
  section_length = (section_binary.b(1, 0..3) << 8) + section_binary.b(2)
  return section_binary.length >= section_length + 3
end

Public Instance Methods

to_epg() click to toggle source
# File lib/definition/event_information_section.rb, line 32
def to_epg
  epg = EPG.new
  events.each do |event|
    attr_hash = {
      :event_id   => event.event_id,
      :start_time => event.start_time.to_s,
      :duration   => event.duration.to_sec
    }
    event.descriptors.each do |desc|
      case desc
      when ShortEventDescriptor
        attr_hash[:name] = desc.event_name.to_utf_8
        attr_hash[:description] = desc.text.to_utf_8
      end
    end
    epg.add(event.event_id, attr_hash) if attr_hash[:name]
  end
  return epg
end