class KML::Route

Docu

Attributes

author[R]
name[R]
points[R]

Public Class Methods

new(route) click to toggle source
# File lib/gpx_kml/kml/route.rb, line 4
def initialize(route)
  return unless route.is_a?(Nokogiri::XML::Element) && !route.xpath('self::xmlns:LinearRing').empty?

  @node = route
  @name = _name
  @points = _points
  @author = _author
  @link = _link
end

Private Instance Methods

_author() click to toggle source
# File lib/gpx_kml/kml/route.rb, line 37
def _author
  elem = @node.xpath('.')
  while elem.xpath('self::xmlns:kml').empty?
    elem = elem.xpath('..')
    return elem.xpath('./atom:author/atom:name/text()').to_s unless elem.xpath('./atom:author').empty?
  end
  ''
end
_name() click to toggle source
# File lib/gpx_kml/kml/route.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/route.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