Class: Hillpace::Import::Tcx::TcxParser
- Inherits:
-
Object
- Object
- Hillpace::Import::Tcx::TcxParser
- Defined in:
- lib/hillpace/import/tcx/tcx_parser.rb
Overview
Parser for TCX files (see en.wikipedia.org/wiki/Training_Center_XML).
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Class Method Summary collapse
-
.from_file(tcx_path) ⇒ TcxParser
Creates a new TcxParser object from a TCX file path.
-
.from_url(tcx_url) ⇒ TcxParser
Creates a new TcxParser object from a TCX file URL.
Instance Method Summary collapse
-
#initialize(tcx_content) ⇒ TcxParser
constructor
Initializes a TcxParser object.
-
#parse ⇒ Route
Parses a TCX document.
Constructor Details
#initialize(tcx_content) ⇒ TcxParser
Initializes a TcxParser object.
10 11 12 13 14 |
# File 'lib/hillpace/import/tcx/tcx_parser.rb', line 10 def initialize(tcx_content) @document = Nokogiri::XML tcx_content @kalman_filter = KalmanFilter.new @srtm = GeoElevation::Srtm.new end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
6 7 8 |
# File 'lib/hillpace/import/tcx/tcx_parser.rb', line 6 def document @document end |
Class Method Details
.from_file(tcx_path) ⇒ TcxParser
Creates a new TcxParser object from a TCX file path.
19 20 21 |
# File 'lib/hillpace/import/tcx/tcx_parser.rb', line 19 def self.from_file(tcx_path) new File.open tcx_path end |
.from_url(tcx_url) ⇒ TcxParser
Creates a new TcxParser object from a TCX file URL.
26 27 28 |
# File 'lib/hillpace/import/tcx/tcx_parser.rb', line 26 def self.from_url(tcx_url) new open tcx_url end |
Instance Method Details
#parse ⇒ Route
Parses a TCX document. Looks for route nodes inside the document and parses them.
33 34 35 36 37 38 39 |
# File 'lib/hillpace/import/tcx/tcx_parser.rb', line 33 def parse routes = Array.new document.search('Activity').each do |route_node| routes << parse_route(route_node) end routes end |