Sha256: 16b44e2b3412a1654c5e15ceb73c0f65a67b0a5386fb65b0c994747f926c736b

Contents?: true

Size: 551 Bytes

Versions: 7

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true

require 'gpx_kml/gpx/point'

module GPX

  class Segment

    def initialize(segment, track)
      return unless segment.is_a?(Nokogiri::XML::Element) && track.is_a?(GPX::Track)
      return if segment.xpath('self::xmlns:trkseg').empty?

      @points = _points segment
      @track = track
    end

    attr_reader :track, :points

    private

    def _points(segment)
      p = []
      segment.xpath('./xmlns:trkpt').each_with_index do |tp, i|
        p[i] = Point.new(tp, self)
      end
      p
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

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