Class: TF1Converter::KmlFile
- Inherits:
-
Object
- Object
- TF1Converter::KmlFile
- Defined in:
- lib/tf1_converter/kml_file.rb
Instance Method Summary collapse
-
#initialize(waypoints, tracks, filename) ⇒ KmlFile
constructor
A new instance of KmlFile.
- #to_xml ⇒ Object
Constructor Details
#initialize(waypoints, tracks, filename) ⇒ KmlFile
Returns a new instance of KmlFile.
6 7 8 9 10 |
# File 'lib/tf1_converter/kml_file.rb', line 6 def initialize(waypoints, tracks, filename) @waypoints = waypoints @tracks = tracks @filename = filename end |
Instance Method Details
#to_xml ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tf1_converter/kml_file.rb', line 12 def to_xml Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.kml('xmlns' => 'http://www.opengis.net/kml/2.2') do xml.Document do write_xml_header(xml) xml.Folder do xml.name "Waypoints" @waypoints.each do |waypoint| write_waypoint_xml(waypoint, xml) end end xml.Folder do xml.name "Tracks" @tracks.each do |track| Kml::TrackNode.new(track, @filename).write_to(xml) end end end end end.to_xml end |