Class: Tracksperanto::Tracker

Inherits:
Array
  • Object
show all
Includes:
Comparable, Casts
Defined in:
lib/tracksperanto/tracker.rb

Overview

Internal representation of a tracker point with keyframes. A Tracker is an array of Keyframe objects and should act and work like one

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Casts

#cast_to_float, #cast_to_int, #cast_to_string, included

Constructor Details

#initialize(object_attribute_hash = {}) {|_self| ... } ⇒ Tracker

Returns a new instance of Tracker.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
# File 'lib/tracksperanto/tracker.rb', line 10

def initialize(object_attribute_hash = {})
  @name = "Tracker"
  __setobj__(Array.new)
  object_attribute_hash.map { |(k, v)| send("#{k}=", v) }
  yield(self) if block_given?
end

Instance Attribute Details

#nameObject

Contains the name of the tracker



7
8
9
# File 'lib/tracksperanto/tracker.rb', line 7

def name
  @name
end

Instance Method Details

#<=>(other_tracker) ⇒ Object

Trackers sort by the position of the first keyframe



26
27
28
# File 'lib/tracksperanto/tracker.rb', line 26

def <=>(other_tracker)
  self[0].frame <=> other_tracker[0].frame
end

#inspectObject



35
36
37
# File 'lib/tracksperanto/tracker.rb', line 35

def inspect
  "<T #{name.inspect} with #{length} keyframes>"
end

#keyframe!(options) ⇒ Object

Create and save a keyframe in this tracker



31
32
33
# File 'lib/tracksperanto/tracker.rb', line 31

def keyframe!(options)
  push(Tracksperanto::Keyframe.new(options))
end

#keyframesObject



21
22
23
# File 'lib/tracksperanto/tracker.rb', line 21

def keyframes
  __getobj__
end

#keyframes=(new_kf_array) ⇒ Object



17
18
19
# File 'lib/tracksperanto/tracker.rb', line 17

def keyframes=(new_kf_array)
  __setobj__(new_kf_array.dup)
end