class KML::Track
Docu
Attributes
link[R]
name[R]
points[R]
Public Class Methods
new(track)
click to toggle source
# File lib/gpx_kml/kml/track.rb, line 4 def initialize(track) return unless track.is_a?(Nokogiri::XML::Element) && !track.xpath('self::xmlns:LineString').empty? @node = track @name = _name @points = _points @author = _author @link = _link end
Private Instance Methods
_link()
click to toggle source
# File lib/gpx_kml/kml/track.rb, line 46 def _link elem = @node.xpath('.') while elem.xpath('self::xmlns:kml').empty? elem = elem.xpath('..') return elem.xpath('./atom:link/@href').to_s unless elem.xpath('./atom:link').empty? end '' end
_name()
click to toggle source
# File lib/gpx_kml/kml/track.rb, line 18 def _name elem = @node.xpath('.') while elem.xpath('self::xmlns:kml').empty? elem = elem.xpath('..') return elem.xpath('./xmlns:name/text()').to_s unless elem.xpath('./xmlns:name').empty? end '' end
_points()
click to toggle source
# File lib/gpx_kml/kml/track.rb, line 27 def _points p = [] points = @node.xpath('./xmlns:coordinates/text()').to_s array_points = points.split(' ') array_points.each_with_index do |ap, i| p[i] = KML::Point.new ap, self, @node end p end