Class: Matterhorn::Smil

Inherits:
Object
  • Object
show all
Defined in:
lib/matterhorn/smil.rb

Overview

Matterhorn::Smil ===

Defined Under Namespace

Classes: Body, Element, Head, Par, Scene, Seq, Track

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSmil

————————————————————————— initialization —



21
22
23
24
# File 'lib/matterhorn/smil.rb', line 21

def initialize()
  @head = Smil::Head.new
  @body = Smil::Body.new
end

Instance Attribute Details

#bodyObject (readonly)

——————————————————————————- attributes —



16
17
18
# File 'lib/matterhorn/smil.rb', line 16

def body
  @body
end

#headObject (readonly)

——————————————————————————- attributes —



16
17
18
# File 'lib/matterhorn/smil.rb', line 16

def head
  @head
end

Instance Method Details

#save(smil_file) ⇒ Object

——————————————————————————— methodes —



29
30
31
32
33
34
35
# File 'lib/matterhorn/smil.rb', line 29

def save(smil_file)
  File.open(smil_file, 'w') do |file|
    file.write(self.to_xml)
  end
  Rails.logger.debug { "Matterhorn::Smil::save | Smil description =\n#{self.to_xml}" }
  true
end

#to_xmlObject



38
39
40
41
42
43
44
45
46
# File 'lib/matterhorn/smil.rb', line 38

def to_xml
  doc = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |bx|
    bx.smil('xmlns' => "http://www.w3.org/ns/SMIL", 'version' => '3.0') do
      head.to_xml(bx)
      body.to_xml(bx)
    end
  end
  doc.to_xml.sub(/version=\"1.0\"/, "version=\"1.1\"")
end