Sha256: ed1eb6ca121a1d685cd0a92cab38b0bdda62aa3064abe59dd48c5feebfc94884

Contents?: true

Size: 768 Bytes

Versions: 7

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

require 'gpx_kml/gpx/point'

module GPX
  # Docu
  class Route
    def initialize(route)
      return unless route.is_a?(Nokogiri::XML::Element) && !route.xpath('self::xmlns:rte').empty?

      @name = route.xpath('./xmlns:name/text()').to_s
      @number = route.xpath('./xmlns:number/text()').to_s
      @description = route.xpath('./xmlns:desc/text()').to_s
      @link = route.xpath('./xmlns:link/@href').to_s
      @points = _points route
    end

    attr_reader :name, :link, :points, :description, :number, :time

    private

    def _points(route)
      route_points = []
      route.xpath('./xmlns:rtept').each_with_index do |rp, i|
        route_points[i] = Point.new(rp, self)
      end
      route_points
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gpx_kml-0.1.4 lib/gpx_kml/gpx/route.rb
gpx_kml-0.1.3 lib/gpx_kml/gpx/route.rb
gpx_kml-0.1.2 lib/gpx_kml/gpx/route.rb
gpx_kml-0.1.1 lib/gpx_kml/gpx/route.rb
gpx_kml-0.1.0 lib/gpx_kml/gpx/route.rb
gpx_kml-0.0.2 lib/gpx_kml/gpx/route.rb
gpx_kml-0.0.1 lib/gpx_kml/gpx/route.rb