Class: TF1Converter::Translation
- Inherits:
-
Object
- Object
- TF1Converter::Translation
- Defined in:
- lib/tf1_converter/translation.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(gpx_file) ⇒ Translation
constructor
A new instance of Translation.
- #into(output_file) ⇒ Object
Constructor Details
#initialize(gpx_file) ⇒ Translation
Returns a new instance of Translation.
14 15 16 17 18 19 |
# File 'lib/tf1_converter/translation.rb', line 14 def initialize(gpx_file) @filename = File.basename(gpx_file.path).split('.').first parsed_gpx = Nokogiri::XML(gpx_file) parsed_gpx.remove_namespaces! @gpx = GpxFile.new(parsed_gpx) end |
Class Method Details
.from(file) ⇒ Object
10 11 12 |
# File 'lib/tf1_converter/translation.rb', line 10 def self.from(file) new(file) end |
Instance Method Details
#into(output_file) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tf1_converter/translation.rb', line 21 def into(output_file) raw_file_name = output_file.path.split('.').first csv_path = raw_file_name + '.csv' CsvFile.new(@gpx.waypoints, csv_path).to_csv! kml = KmlFile.new(@gpx.waypoints, @gpx.tracks, @filename).to_xml output_file.puts kml output_file.close kmz = KmzFile.assemble!(raw_file_name) end |