Class: CineSync::FrameAnnotation
- Inherits:
-
Object
- Object
- CineSync::FrameAnnotation
- Defined in:
- lib/cinesync/xml.rb,
lib/cinesync/frame_annotation.rb
Constant Summary collapse
- DrawingObjectElements =
eFrameAnnotation = element annotation {
attribute frame { tFrameNumber } & eNotes? & eObject* }
%w(line erase circle arrow text)
Instance Attribute Summary collapse
-
#drawing_objects ⇒ Object
Returns the value of attribute drawing_objects.
-
#frame ⇒ Object
Returns the value of attribute frame.
-
#notes ⇒ Object
Returns the value of attribute notes.
Class Method Summary collapse
Instance Method Summary collapse
- #default? ⇒ Boolean
-
#initialize(frame_num) ⇒ FrameAnnotation
constructor
A new instance of FrameAnnotation.
- #to_xml(x) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(frame_num) ⇒ FrameAnnotation
Returns a new instance of FrameAnnotation.
5 6 7 8 9 |
# File 'lib/cinesync/frame_annotation.rb', line 5 def initialize(frame_num) @frame = frame_num @notes = '' @drawing_objects = [] end |
Instance Attribute Details
#drawing_objects ⇒ Object
Returns the value of attribute drawing_objects.
3 4 5 |
# File 'lib/cinesync/frame_annotation.rb', line 3 def drawing_objects @drawing_objects end |
#frame ⇒ Object
Returns the value of attribute frame.
3 4 5 |
# File 'lib/cinesync/frame_annotation.rb', line 3 def frame @frame end |
#notes ⇒ Object
Returns the value of attribute notes.
3 4 5 |
# File 'lib/cinesync/frame_annotation.rb', line 3 def notes @notes end |
Class Method Details
.load(elem) ⇒ Object
426 427 428 429 430 431 432 433 |
# File 'lib/cinesync/xml.rb', line 426 def self.load(elem) returning self.new(elem.attribute('frame').value.to_i) do |ann| ann.notes = elem.elements['notes'].andand.text || '' DrawingObjectElements.each do |obj_name| ann.drawing_objects += elem.get_elements(obj_name) end end end |
Instance Method Details
#default? ⇒ Boolean
11 12 13 |
# File 'lib/cinesync/frame_annotation.rb', line 11 def default? notes.empty? and drawing_objects.empty? end |
#to_xml(x) ⇒ Object
412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/cinesync/xml.rb', line 412 def to_xml(x) fail "#{self.inspect}: Invalid" unless valid? return if default? attrs = {} attrs['frame'] = frame x.annotation(attrs) { x.notes(notes) unless notes.empty? drawing_objects.each {|obj| x << obj.to_s } } end |
#valid? ⇒ Boolean
15 16 17 |
# File 'lib/cinesync/frame_annotation.rb', line 15 def valid? frame >= 1 rescue false end |