Class: TF1Converter::Gpx::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/tf1_converter/gpx/track.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml_node, color_map = TF1Converter::Config.colors) ⇒ Track

Returns a new instance of Track.



6
7
8
9
# File 'lib/tf1_converter/gpx/track.rb', line 6

def initialize(xml_node, color_map = TF1Converter::Config.colors)
  @node = xml_node
  @color_map = color_map
end

Instance Method Details

#coordinate_stringObject



24
25
26
27
# File 'lib/tf1_converter/gpx/track.rb', line 24

def coordinate_string
  trackpoints = @node.xpath('trkseg/trkpt').map{ |node| Trackpoint.new(node) }
  trackpoints.inject([]) { |points, tp| points << tp.to_s }.join(' ')
end

#display_colorObject



15
16
17
18
19
20
21
22
# File 'lib/tf1_converter/gpx/track.rb', line 15

def display_color
  color_node = @node.xpath('extensions/TrackExtension/DisplayColor').first
  if color_node
    @color_map[color_node.text]
  else
    'f0000080'
  end
end

#nameObject



11
12
13
# File 'lib/tf1_converter/gpx/track.rb', line 11

def name
  @node.xpath('name').first.text
end