Class: Tracksperanto::Import::Base

Inherits:
Object
  • Object
show all
Includes:
BlockInit, Casts, Safety, ZipTuples
Defined in:
lib/import/base.rb

Overview

The base class for all the import modules. By default, when you inherit from this class the inherited class will be included in the list of supported Tracksperanto importers. The API that an importer should present is very basic, and consists only of a few methods. The main method is parse(io) which should return an array of Tracker objects.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ZipTuples

#zip_curve_tuples

Methods included from BlockInit

#initialize

Methods included from Casts

#cast_to_float, #cast_to_int, #cast_to_string, included

Methods included from Safety

included, #safe_reader

Instance Attribute Details

#heightObject

The original height of the comp, same conventions as for width apply



26
27
28
# File 'lib/import/base.rb', line 26

def height
  @height
end

#progress_blockObject

Tracksperanto will assign a proc that reports the status of the import to the caller. This block is automatically used by report_progress IF the proc is assigned. Should the proc be nil, the report_progress method will just pass (so you don’t need to check for nil yourself)



14
15
16
# File 'lib/import/base.rb', line 14

def progress_block
  @progress_block
end

#widthObject

The original width of the tracked image. If you need to know the width for your specific format and cannot autodetect it, Trakcksperanto will assign the passed width and height to the importer object before running the import. If not, you can replace the assigned values with your own. At the end of the import procedure, Tracksperanto will read the values from you again and will use the read values for determining the original comp size. width and height MUST return integer values after the import completes



23
24
25
# File 'lib/import/base.rb', line 23

def width
  @width
end

Class Method Details

.autodetects_size?Boolean

Return true from this method if your importer can deduce the comp size from the passed file

Returns:

  • (Boolean)


51
52
53
# File 'lib/import/base.rb', line 51

def self.autodetects_size?
  false
end

.distinct_file_extObject

Return an extension WITH DOT if this format has a typical extension that you can detect



40
41
42
# File 'lib/import/base.rb', line 40

def self.distinct_file_ext
  nil
end

.human_nameObject

Should return a human-readable (read: properly capitalized and with spaces) name of the import format



46
47
48
# File 'lib/import/base.rb', line 46

def self.human_name
  "Abstract import format"
end

.inherited(by) ⇒ Object

Used to register your importer in the list of supported formats



33
34
35
36
# File 'lib/import/base.rb', line 33

def self.inherited(by)
  Tracksperanto.importers << by
  super
end

Instance Method Details

#parse(track_file_io) ⇒ Object

The main method of the parser. Will receive an IO handle to the file being imported, and should return an array of Tracksperanto::Tracker objects containing keyframes. If you have a problem doing an import, raise from here.



64
65
66
# File 'lib/import/base.rb', line 64

def parse(track_file_io)
  []
end

#report_progress(message) ⇒ Object

Call this method to tell what you are doing. This gets propagated to the caller automatically, or gets ignored if the caller did not request any progress reports



57
58
59
# File 'lib/import/base.rb', line 57

def report_progress(message)
  @progress_block.call(message) if @progress_block
end