class Avdata

Attributes

apt_file[RW]
directory[RW]

Public Class Methods

new(args) click to toggle source
# File lib/avdata.rb, line 9
def initialize args
  args.each do |k,v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
  
  if (self.directory != nil) && (File.directory?(self.directory))
    if File.exists?(File.expand_path('APT.txt', self.directory))
      self.apt_file = File.expand_path('APT.txt', self.directory)
    end
  end
  
end

Public Instance Methods

get_airports() click to toggle source
# File lib/avdata.rb, line 22
def get_airports
  if self.apt_file
    return get_rows(self.apt_file,'APT')
    
  else
    return []
  end
  
end
get_rows(file,prefix) click to toggle source
# File lib/avdata.rb, line 32
def get_rows(file,prefix)
  
  results = []
  
  f = File.new(file, "r")
  while line = f.gets
    
    ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
    valid_line = ic.iconv(line + ' ')[0..-2]
    
    if valid_line.match(/^#{prefix}/)
      results << Airport_record.new(valid_line)
    end
  end
  
  return results
  
end