Class: CineSync::MediaFile
- Defined in:
- lib/cinesync/xml.rb,
lib/cinesync/media_file.rb
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#color_grading ⇒ Object
Returns the value of attribute color_grading.
-
#locator ⇒ Object
Returns the value of attribute locator.
-
#mask ⇒ Object
Returns the value of attribute mask.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#pixel_ratio ⇒ Object
Returns the value of attribute pixel_ratio.
-
#zoom_state ⇒ Object
Returns the value of attribute zoom_state.
Attributes inherited from MediaBase
#active, #current_frame, #groups, #play_range, #user_data
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(locator_arg = nil) ⇒ MediaFile
constructor
A new instance of MediaFile.
-
#to_xml(x) ⇒ Object
eMedia |= element media { # Normal media file MediaBase & element name { xsd:string { minLength = “1” } } & element locators { eLocator+ } & eNotes? & eZoomState? & ePixelRatio? & eMask? & eColorGrading? & eFrameAnnotation* }.
- #uses_pro_features? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(locator_arg = nil) ⇒ MediaFile
Returns a new instance of MediaFile.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cinesync/media_file.rb', line 40 def initialize(locator_arg = nil) super() @name = '' @notes = '' @annotations = Hash.new {|h,k| h[k] = FrameAnnotation.new(k) } def @annotations.<<(ann) self[ann.frame] = ann end @locator = MediaLocator.new(locator_arg) @name = File.basename(@locator.path || @locator.url.andand.path || '') @zoom_state = ZoomState.new @pixel_ratio = PixelRatio.new @mask = Mask.new @color_grading = ColorGrading.new end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
37 38 39 |
# File 'lib/cinesync/media_file.rb', line 37 def annotations @annotations end |
#color_grading ⇒ Object
Returns the value of attribute color_grading.
38 39 40 |
# File 'lib/cinesync/media_file.rb', line 38 def color_grading @color_grading end |
#locator ⇒ Object
Returns the value of attribute locator.
36 37 38 |
# File 'lib/cinesync/media_file.rb', line 36 def locator @locator end |
#mask ⇒ Object
Returns the value of attribute mask.
38 39 40 |
# File 'lib/cinesync/media_file.rb', line 38 def mask @mask end |
#name ⇒ Object
Returns the value of attribute name.
36 37 38 |
# File 'lib/cinesync/media_file.rb', line 36 def name @name end |
#notes ⇒ Object
Returns the value of attribute notes.
36 37 38 |
# File 'lib/cinesync/media_file.rb', line 36 def notes @notes end |
#pixel_ratio ⇒ Object
Returns the value of attribute pixel_ratio.
38 39 40 |
# File 'lib/cinesync/media_file.rb', line 38 def pixel_ratio @pixel_ratio end |
#zoom_state ⇒ Object
Returns the value of attribute zoom_state.
38 39 40 |
# File 'lib/cinesync/media_file.rb', line 38 def zoom_state @zoom_state end |
Class Method Details
.<<(ann) ⇒ Object
45 46 47 |
# File 'lib/cinesync/media_file.rb', line 45 def @annotations.<<(ann) self[ann.frame] = ann end |
.load(elem) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/cinesync/xml.rb', line 145 def self.load(elem) returning self.new do |m| common_load(elem, m) m.name = elem.elements['name'].text m.locator = MediaLocator.load(elem.elements['locators']) m.notes = elem.elements['notes'].andand.text || '' elem.get_elements('annotation').each do |ann_elem| m.annotations << FrameAnnotation.load(ann_elem) end # Load optional structures %w(zoomState pixelRatio mask colorGrading).each do |camel_name| set_sym = (camel_name + '=').underscore.to_sym e = elem.elements[camel_name] next if e.nil? obj = ('CineSync::' + camel_name.camelize).constantize.load(e) m.send(set_sym, obj) end end end |
Instance Method Details
#to_xml(x) ⇒ Object
eMedia |= element media {
# Normal media file
MediaBase &
element name { xsd:string { minLength = "1" } } &
element locators { eLocator+ } &
eNotes? &
eZoomState? &
ePixelRatio? &
eMask? &
eColorGrading? &
eFrameAnnotation* }
129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/cinesync/xml.rb', line 129 def to_xml(x) super(x) do |x| x.name(name) locator.to_xml(x) x.notes(notes) unless notes.empty? zoom_state.to_xml(x) pixel_ratio.to_xml(x) mask.to_xml(x) color_grading.to_xml(x) annotations.values.each {|ann| ann.to_xml(x) } end end |
#uses_pro_features? ⇒ Boolean
58 59 60 |
# File 'lib/cinesync/media_file.rb', line 58 def uses_pro_features? super || [zoom_state, pixel_ratio, mask, color_grading].any? {|x| not x.default? } end |
#valid? ⇒ Boolean
62 63 64 65 66 67 68 |
# File 'lib/cinesync/media_file.rb', line 62 def valid? super and name.length >= 1 and locator and locator.valid? and annotations.values.all? {|ann| ann.valid? } and [zoom_state, pixel_ratio, mask, color_grading].all? {|x| x.valid? } end |