Sha256: 5c9e574eb95c6238faaf8c8a5963f672cd8fb1f172615f598acb0917e52a51d2
Contents?: true
Size: 921 Bytes
Versions: 2
Compression:
Stored size: 921 Bytes
Contents
# encoding: utf-8 module GpxTrackGenerator # A gpx file class GpxFile private attr_reader :path public def initialize(path) @path = path end # Return nodes def nodes document = Nokogiri::XML('') node_set = Nokogiri::XML::NodeSet.new(document) node_set += extract_route_nodes unless extract_route_nodes.empty? node_set += extract_track_nodes unless extract_track_nodes.empty? node_set end # Return file name def file_name File.basename(path) end private def extract_route_nodes node_set = Nokogiri::XML(File.open(path)).remove_namespaces!.css('rtept') node_set.each { |n| n.name = 'trkpt' } node_set end def extract_track_nodes node_set = Nokogiri::XML(File.open(path)).remove_namespaces!.css('trkpt') node_set.each { |n| n.name = 'trkpt' } node_set end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gpx_track_generator-0.3.5 | lib/gpx_track_generator/gpx_file.rb |
gpx_track_generator-0.3.3 | lib/gpx_track_generator/gpx_file.rb |