Class: Tracksperanto::Import::PFTrack

Inherits:
Base
  • Object
show all
Defined in:
lib/import/pftrack.rb

Overview

TODO: this should be rewritten as a proper state-machine parser

Constant Summary collapse

CHARACTERS_OR_QUOTES =
/[AZaz"]/
INTS =
/^\d+$/

Instance Attribute Summary

Attributes inherited from Base

#height, #io, #progress_block, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

autodetects_size?, inherited, #report_progress

Methods included from BlockInit

#initialize

Methods included from ZipTuples

#zip_curve_tuples

Methods included from ConstName

#const_name, included

Methods included from Safety

included, #safe_reader

Methods included from Casts

#cast_to_float, #cast_to_int, #cast_to_string, included

Class Method Details

.distinct_file_extObject



8
9
10
# File 'lib/import/pftrack.rb', line 8

def self.distinct_file_ext
  ".2dt"
end

.human_nameObject



4
5
6
# File 'lib/import/pftrack.rb', line 4

def self.human_name
  "PFTrack/PFMatchit .2dt file"
end

Instance Method Details

#eachObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/import/pftrack.rb', line 15

def each
  until @io.eof?
    line = @io.gets
    next if (!line || line =~ /^#/)
    
    if line =~ CHARACTERS_OR_QUOTES # Tracker with a name
      name = unquote(line.strip)
      report_progress("Reading tracker #{name}")
      parse_trackers(name, @io, &Proc.new)
    end
  end
end