Class: Gooby::Track

Inherits:
GoobyObject show all
Defined in:
lib/gooby_track.rb

Overview

Instances of this class represent a <Track> aggregate object from a Forerunner

XML file.  Note that a <Run> may contain more than one <Track> aggregates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GoobyKernel

#character_align, #default_delimiter, #invalid_altitude, #invalid_heartbeat, #invalid_latitude, #invalid_longitude, #invalid_time, #project_author, #project_copyright, #project_date, #project_embedded_comment, #project_license, #project_name, #project_version_number, #project_year, #read_as_ascii_lines, #read_lines, #strip_lines, #tokenize

Constructor Details

#initialize(num = 0, descr = '') ⇒ Track

Returns a new instance of Track.



20
21
22
23
24
# File 'lib/gooby_track.rb', line 20

def initialize(num=0, descr='')
  @number = num      
  @descr  = descr
  @trackpoints = Array.new      
end

Instance Attribute Details

#descrObject (readonly)

Returns the value of attribute descr.



18
19
20
# File 'lib/gooby_track.rb', line 18

def descr
  @descr
end

#numberObject (readonly)

Returns the value of attribute number.



18
19
20
# File 'lib/gooby_track.rb', line 18

def number
  @number
end

#trackpointsObject (readonly)

Returns the value of attribute trackpoints.



18
19
20
# File 'lib/gooby_track.rb', line 18

def trackpoints
  @trackpoints
end

Instance Method Details

#add_trackpoint(tkpt) ⇒ Object



28
29
30
# File 'lib/gooby_track.rb', line 28

def add_trackpoint(tkpt)
  @trackpoints.push(tkpt)   
end

#dumpObject



40
41
42
43
# File 'lib/gooby_track.rb', line 40

def dump
  puts "Track: '#{@descr}'  tkpts: #{size}"
  @trackpoints.each { |tkpt| puts tkpt.to_csv } 
end

#sizeObject



32
33
34
# File 'lib/gooby_track.rb', line 32

def size
  @trackpoints.size
end

#to_sObject



36
37
38
# File 'lib/gooby_track.rb', line 36

def to_s
  return "Trk: #{@descr} tkpts: #{size}"
end