Class: TF1Converter::CsvFile

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

Instance Method Summary collapse

Constructor Details

#initialize(waypoints, path) ⇒ CsvFile

Returns a new instance of CsvFile.



5
6
7
8
# File 'lib/tf1_converter/csv_file.rb', line 5

def initialize(waypoints, path)
  @waypoints = waypoints
  @path = path
end

Instance Method Details

#to_csv!Object



10
11
12
13
14
15
16
17
# File 'lib/tf1_converter/csv_file.rb', line 10

def to_csv!
  CSV.open(@path, 'wb') do |csv|
    csv << ['filename', 'name', 'meaning', 'time', 'lat', 'long', 'usng', 'elevation']
    @waypoints.each do |wp|
      csv << [@path.split('.').first, wp.name, wp.icon_meaning, wp.timestamp, wp.lat, wp.long, wp.usng, wp.elevation]
    end
  end
end