Module: FlightParse

Included in:
Hasami
Defined in:
lib/hasami/flight_parse.rb

Instance Method Summary collapse

Instance Method Details

#flights_parseObject



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

def flights_parse
  @flights = []

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

#source_url(url = nil) ⇒ Object

attr_accessor :url, :flights



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

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