Sha256: 4cab9e5dbc42e4ae5c7b5a287b449637265616f5139cc8bef7b32924ec38e9f8

Contents?: true

Size: 394 Bytes

Versions: 3

Compression:

Stored size: 394 Bytes

Contents

module FlightParse
  # attr_accessor :url, :flights

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

  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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Alohaha-0.0.3 lib/alohaha/flight_parse.rb
Alohaha-0.0.2 lib/alohaha/flight_parse.rb
Alohaha-0.0.1 lib/alohaha/flight_parse.rb