Class: PotaCsvToAdif::LogFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-pota-csv-to-adif.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ LogFile

Returns a new instance of LogFile.



25
26
27
# File 'lib/ruby-pota-csv-to-adif.rb', line 25

def initialize(file_path)
  @file_path = file_path
end

Instance Method Details

#convertObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby-pota-csv-to-adif.rb', line 29

def convert
  file = File.open(file_path)
  csv = CSV.new(file, headers: true)
  File.open("#{file_path[0...file_path.rindex('.')]}.adi", 'w') do |adif_file|
    adif_file.puts header

    csv.each do |row|
      adif_file.puts "#{field('CALL', row)}#{field('QSO_DATE', row)}#{field('TIME_ON', row)}#{field('BAND', row)}#{field('MODE', row)}#{field('OPERATOR', row)}<MY_SIG:4>POTA #{field('MY_SIG_INFO', row)}#{field('SIG_INFO', row)}#{field('STATION_CALLSIGN', row)}<EOR>"
    end
  end
end