Sha256: c8561adfb0fd65a52d3782f3f80be83cb0825d7faa645de4277968b090031522

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 Bytes

Contents

# Internal representation of a tracker point with keyframes. A Tracker is an array of Keyframe objects and should act and work like one
class Tracksperanto::Tracker < DelegateClass(Array)
  include Tracksperanto::Casts
  include Comparable
  
  # Contains the name of the tracker
  attr_accessor :name
  cast_to_string :name
  
  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
  
  def keyframes=(new_kf_array)
    __setobj__(new_kf_array.dup)
  end
  
  def keyframes
    __getobj__
  end
  
  # Trackers sort by the position of the first keyframe
  def <=>(other_tracker)
    self[0].frame <=> other_tracker[0].frame
  end
  
  # Create and save a keyframe in this tracker
  def keyframe!(options)
    push(Tracksperanto::Keyframe.new(options))
  end
  
  def inspect
    "<T #{name.inspect} with #{length} keyframes>"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tracksperanto-1.2.6 lib/tracksperanto/tracker.rb
tracksperanto-1.2.4 lib/tracksperanto/tracker.rb
tracksperanto-1.2.3 lib/tracksperanto/tracker.rb
tracksperanto-1.2.2 lib/tracksperanto/tracker.rb
tracksperanto-1.2.1 lib/tracksperanto/tracker.rb
tracksperanto-1.2.0 lib/tracksperanto/tracker.rb