Class: CineSync::MediaBase

Inherits:
Object
  • Object
show all
Defined in:
lib/cinesync/xml.rb,
lib/cinesync/media_file.rb

Direct Known Subclasses

GroupMovie, MediaFile

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMediaBase

Returns a new instance of MediaBase.



16
17
18
19
20
21
22
23
# File 'lib/cinesync/media_file.rb', line 16

def initialize
  @user_data = ''
  @active = false
  @current_frame = 1

  @groups = []
  @play_range = PlayRange.new
end

Instance Attribute Details

#activeObject Also known as: active?

Returns the value of attribute active.



11
12
13
# File 'lib/cinesync/media_file.rb', line 11

def active
  @active
end

#current_frameObject

Returns the value of attribute current_frame.



11
12
13
# File 'lib/cinesync/media_file.rb', line 11

def current_frame
  @current_frame
end

#groupsObject

Returns the value of attribute groups.



12
13
14
# File 'lib/cinesync/media_file.rb', line 12

def groups
  @groups
end

#play_rangeObject

Returns the value of attribute play_range.



12
13
14
# File 'lib/cinesync/media_file.rb', line 12

def play_range
  @play_range
end

#user_dataObject

Returns the value of attribute user_data.



11
12
13
# File 'lib/cinesync/media_file.rb', line 11

def user_data
  @user_data
end

Class Method Details

.load(elem) ⇒ Object



96
97
98
99
# File 'lib/cinesync/xml.rb', line 96

def self.load(elem)
  klass = elem.elements['groupMovie'] ? GroupMovie : MediaFile
  klass.load(elem)
end

Instance Method Details

#to_xml(x) ⇒ Object

MediaBase =

aUserData? &
attribute active { tBool }? &
attribute currentFrame { tFrameNumber }? &
eGroup* &
ePlayRange?


80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/cinesync/xml.rb', line 80

def to_xml(x)
  fail "#{self.inspect}: Invalid" unless valid?

  attrs = {}
  attrs['userData'] = user_data unless user_data.empty?
  attrs['active'] = active? if active?
  attrs['currentFrame'] = current_frame if current_frame != 1

  x.media(attrs) {
    yield x
    groups.each {|g| x.group(g) }
    play_range.to_xml(x)
  }
end

#uses_pro_features?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/cinesync/media_file.rb', line 25

def uses_pro_features?
  false
end

#valid?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cinesync/media_file.rb', line 29

def valid?
  current_frame >= 1 and play_range.valid?
end