Module: FlightParse

Included in:
Alohaha
Defined in:
lib/alohaha/flight_parse.rb

Instance Method Summary collapse

Instance Method Details

#flights_parseObject



8
9
10
11
12
13
14
15
16
# File 'lib/alohaha/flight_parse.rb', line 8

def flights_parse
  @flights = []

  ic = Iconv.new('UTF-8', 'BIG5')
  row_data = ic.iconv(open(@url).read)
  row_data.each_line do |line|
    @flights << Flight.new(line.split(',').map {|al| al = al.strip})
  end
end

#source_url(url = nil) ⇒ Object

attr_accessor :url, :flights



4
5
6
# File 'lib/alohaha/flight_parse.rb', line 4

def source_url(url = nil)
  @url = url.nil? || url.length == 0 ? Settings::FLIGHT_URL : url
end