Class: GPX::GPX
- Inherits:
-
Object
- Object
- GPX::GPX
- Defined in:
- lib/gpx/gpx.rb
Overview
Class is responsible for parsing GPX files and calculate track statistics
Instance Attribute Summary collapse
-
#average_speed ⇒ Object
readonly
Returns the value of attribute average_speed.
-
#distances ⇒ Object
readonly
Returns the value of attribute distances.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#max_speed ⇒ Object
readonly
Returns the value of attribute max_speed.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#points_count ⇒ Object
readonly
Returns the value of attribute points_count.
-
#speeds ⇒ Object
readonly
Returns the value of attribute speeds.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#times ⇒ Object
readonly
Returns the value of attribute times.
Instance Method Summary collapse
-
#initialize(path) ⇒ GPX
constructor
A new instance of GPX.
Constructor Details
#initialize(path) ⇒ GPX
Returns a new instance of GPX.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/gpx/gpx.rb', line 70 def initialize(path) @doc = nil begin path = open(path) doc = Nokogiri::XML(path) rescue raise GPXInvalidFileException end # raise GPXInvalidFileException if doc.children.empty? @points = [] @dates = [] doc.search('trkpt').map do |el| @dates.push Time.parse(el.at('time').text) @points.push GeoPoint.new( latitude: el['lat'].to_f, longitude: el['lon'].to_f, elevation: el.at('ele').text.to_f ) end end |
Instance Attribute Details
#average_speed ⇒ Object (readonly)
Returns the value of attribute average_speed.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def average_speed @average_speed end |
#distances ⇒ Object (readonly)
Returns the value of attribute distances.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def distances @distances end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def end_date @end_date end |
#max_speed ⇒ Object (readonly)
Returns the value of attribute max_speed.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def max_speed @max_speed end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def points @points end |
#points_count ⇒ Object (readonly)
Returns the value of attribute points_count.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def points_count @points_count end |
#speeds ⇒ Object (readonly)
Returns the value of attribute speeds.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def speeds @speeds end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def start_date @start_date end |
#times ⇒ Object (readonly)
Returns the value of attribute times.
8 9 10 |
# File 'lib/gpx/gpx.rb', line 8 def times @times end |