class Gippix::Gpx
Public Instance Methods
parse()
click to toggle source
# File lib/gippix.rb, line 109 def parse return self if @doc.nil? @description = @name = @doc.xpath('//xmlns:gpx/xmlns:trk[1]/xmlns:name').inner_text @points = parse_points @doc = nil self rescue Nokogiri::XML::XPath::SyntaxError raise ParseError.new("Could not find appropriate gpx root element") end
parse_date(doc)
click to toggle source
# File lib/gippix.rb, line 132 def parse_date(doc) DateTime.parse doc.inner_text rescue nil end
parse_points()
click to toggle source
# File lib/gippix.rb, line 122 def parse_points doc.xpath('//xmlns:gpx/xmlns:trk//xmlns:trkpt').map { |pt| Point.new( pt['lat'].to_f, pt['lon'].to_f, pt.xpath('xmlns:ele').inner_text.to_f, parse_date(pt.xpath('xmlns:time')) ) } end