Class: TF1Converter::KmlFile

Inherits:
Object
  • Object
show all
Defined in:
lib/tf1_converter/kml_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(waypoints, tracks, filename) ⇒ KmlFile

Returns a new instance of KmlFile.



3
4
5
6
7
# File 'lib/tf1_converter/kml_file.rb', line 3

def initialize(waypoints, tracks, filename)
  @waypoints = waypoints
  @tracks = tracks
  @filename = filename
end

Instance Method Details

#to_xmlObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tf1_converter/kml_file.rb', line 9

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|
            write_track_xml(track, xml)
          end
        end

      end
    end
  end.to_xml
end