Class: GPXReader::Gpx
- Inherits:
-
Object
- Object
- GPXReader::Gpx
- Defined in:
- lib/gpx_reader/gpx.rb
Instance Attribute Summary collapse
-
#boundaries ⇒ Object
Returns the value of attribute boundaries.
-
#creator ⇒ Object
Returns the value of attribute creator.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#highest_point ⇒ Object
Returns the value of attribute highest_point.
-
#lowest_point ⇒ Object
Returns the value of attribute lowest_point.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespaces ⇒ Object
Returns the value of attribute namespaces.
-
#time ⇒ Object
Returns the value of attribute time.
-
#tracks ⇒ Object
Returns the value of attribute tracks.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(file) ⇒ Gpx
constructor
read the file containing the tracks get the different information of the file get the tracks.
Constructor Details
#initialize(file) ⇒ Gpx
read the file containing the tracks get the different information of the file get the tracks
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gpx_reader/gpx.rb', line 29 def initialize(file) if file.is_a?(File) @gpx=Nokogiri::XML(File.open(file)) else @gpx=Nokogiri::XML(file) end @creator = @gpx.at_css("gpx")["creator"] rescue nil @time = Time.parse(@gpx.at_css("metadata time").text) rescue nil @tracks = [] @gpx.css("trk").each do |trk| trk = Track.new(trk) @tracks << trk end # get name spaces ns = @gpx.collect_namespaces # Strip the leading xmlns: from each namespace key, and store in a new hash @namespaces= {} ns.each_pair do |key, value| @namespaces[key.sub(/^xmlns:/, '')] = value end end |
Instance Attribute Details
#boundaries ⇒ Object
Returns the value of attribute boundaries.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def boundaries @boundaries end |
#creator ⇒ Object
Returns the value of attribute creator.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def creator @creator end |
#duration ⇒ Object
Returns the value of attribute duration.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def duration @duration end |
#highest_point ⇒ Object
Returns the value of attribute highest_point.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def highest_point @highest_point end |
#lowest_point ⇒ Object
Returns the value of attribute lowest_point.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def lowest_point @lowest_point end |
#name ⇒ Object
Returns the value of attribute name.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def name @name end |
#namespaces ⇒ Object
Returns the value of attribute namespaces.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def namespaces @namespaces end |
#time ⇒ Object
Returns the value of attribute time.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def time @time end |
#tracks ⇒ Object
Returns the value of attribute tracks.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def tracks @tracks end |
#version ⇒ Object
Returns the value of attribute version.
25 26 27 |
# File 'lib/gpx_reader/gpx.rb', line 25 def version @version end |