Class: ProgramTV::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/program-tv/writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Writer

Returns a new instance of Writer.



6
7
8
9
10
# File 'lib/program-tv/writer.rb', line 6

def initialize(data)
  @data = data
  @xml = Builder::XmlMarkup.new( :indent => 2 )
  @xml.instruct! :xml, :encoding => "UTF-8"
end

Instance Method Details

#runObject

Runs dynamic-sprites command.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/program-tv/writer.rb', line 14

def run
  @xml.tv do |tv|
    @data.flatten.each do |element|
      tv.programme do |p|
        p.title   element[:title]
        p.channel element[:channel]
        p.start   element[:start]
        p.end     element[:end]
      end
    end
  end
end