class Matterhorn::Smil::Element
Matterhorn::Smil::Element
===¶ ↑
Attributes
duration[R]
——————————————————————————- attributes —
end_point[R]
——————————————————————————- attributes —
parent[R]
——————————————————————————- attributes —
rel_begin[R]
——————————————————————————- attributes —
start_point[R]
——————————————————————————- attributes —
Public Class Methods
new(parent = nil)
click to toggle source
————————————————————————— initialization —
# File lib/matterhorn/smil.rb, line 128 def initialize(parent = nil) @start_point = nil @end_point = nil @rel_begin = nil @duration = nil @scene_list = Array.new @parent = parent end
Public Instance Methods
add_scene(file, clip_begin, clip_end)
click to toggle source
# File lib/matterhorn/smil.rb, line 152 def add_scene(file, clip_begin, clip_end) scene = Smil::Scene.new(self, file, clip_begin, clip_end) @scene_list.sort! { |a, b| a.clip_begin <=> b.clip_begin } @scene_list << scene scene end
attr_list()
click to toggle source
——————————————————————————— methodes —
# File lib/matterhorn/smil.rb, line 140 def attr_list attr_list = Hash.new if !@rel_begin.nil? attr_list[:begin] = "#{(@rel_begin * 1000).round.to_s}ms" end if !@duration.nil? attr_list[:dur] = "#{(@duration * 1000).round.to_s}ms" end attr_list end
Protected Instance Methods
duration=(new_duration)
click to toggle source
# File lib/matterhorn/smil.rb, line 201 def duration=(new_duration) if new_duration.kind_of? Fixnum # duration is in ms new_duration = new_duration / 1000 elsif duration.respond_to?('to_f') # duration is in s new_duration = new_duration.to_f else new_duration = nil end @end_point = start_point + new_duration if !start_point.nil? && !new_duration.nil? @duration = new_duration end
end_point=(new_end_point)
click to toggle source
# File lib/matterhorn/smil.rb, line 176 def end_point=(new_end_point) if new_end_point.kind_of? String # end_point is an absolut time position and must be in the format 2013-12-02T14:12:42.364 new_end_point = new_end_point.to_datetime.to_f elsif new_end_point.respond_to?('to_f') new_end_point = new_end_point.to_f else new_end_point = nil end @end_point = new_end_point end
propagate(parent_elem)
click to toggle source
# File lib/matterhorn/smil.rb, line 238 def propagate(parent_elem) end
rel_begin=(new_rel_begin)
click to toggle source
# File lib/matterhorn/smil.rb, line 189 def rel_begin=(new_rel_begin) if new_rel_begin.kind_of? Fixnum new_rel_begin = new_rel_begin / 1000.0 elsif new_rel_begin.respond_to?('to_f') new_rel_begin = new_rel_begin.to_f else new_rel_begin = nil end @rel_begin = new_rel_begin end
start_point=(new_start_point)
click to toggle source
———————————————————————— protected section —
# File lib/matterhorn/smil.rb, line 163 def start_point=(new_start_point) if new_start_point.kind_of? String # start_point is an absolut time position and must be in the format 2013-12-02T14:12:42.364 new_start_point = new_start_point.to_datetime.to_f elsif new_start_point.respond_to?('to_f') new_start_point = new_start_point.to_f else new_start_point = nil end @start_point = new_start_point end
update(sub_elem)
click to toggle source
# File lib/matterhorn/smil.rb, line 216 def update(sub_elem) if !sub_elem.start_point.nil? && (start_point.nil? || start_point > sub_elem.start_point) @start_point = sub_elem.start_point else # do not update start_point end if !sub_elem.end_point.nil? && (end_point.nil? || end_point < sub_elem.end_point) @end_point = sub_elem.end_point else # do not update start_point end if !start_point.nil? && !end_point.nil? @duration = end_point - start_point end # update parent if any parent.update(self) if !parent.nil? propagate(self) if parent.nil? end