class Airhelp::Record
Attributes
carrier_code[RW]
carrier_code_type[RW]
flight_date[RW]
flight_number[RW]
id[RW]
Public Class Methods
headers(params=nil)
click to toggle source
# File lib/airhelp/record.rb, line 39 def self.headers(params=nil) %w(id carrier_code carrier_code_type flight_number flight_date #{params}) end
new(params)
click to toggle source
# File lib/airhelp/record.rb, line 16 def initialize(params) params.each do |key, value| instance_variable_set("@#{key}", value) end end
Public Instance Methods
process()
click to toggle source
# File lib/airhelp/record.rb, line 22 def process if @carrier_code =~ /\A[a-zA-Z]{3}\z/ @carrier_code_type = 'ICAO' elsif @carrier_code =~ /\A[a-zA-Z]{2}\*?\z/ @carrier_code_type = 'IATA' else @carrier_code_type = 'unknown' errors.add(:carrier_code_type, 'format is unknown') end end
to_a()
click to toggle source
# File lib/airhelp/record.rb, line 33 def to_a array = [id, carrier_code, carrier_code_type, flight_number, flight_date] array.push(errors.full_messages.join(';')) if errors.any? array end