Sha256: 7e070c077e6fd3cac64602e504632575f47ecc77dff08cef252edd8b57227f28

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

class Destination
  include Virtus.model

  attribute :iata,  String
  attribute :en,    String
  attribute :zh,    String
end

class Flight
  include Virtus.model

  attribute :terminal,          String    #1: T1, 2:T2
  attribute :kind,              String    #A: Arrivals, D: Departure
  attribute :code,              String
  attribute :code_zh,           String
  attribute :flight,            String
  attribute :gate,              String

  attribute :datetime,          DateTime
  attribute :expected_datetime, DateTime

  attribute :destination,       Destination
  attribute :flight_status,     String

  attribute :aircraft_type,     String
  attribute :other_route,       Destination
  attribute :baggage_carousel,  String
  attribute :check_in_counter,  String

  attribute :raw,               Array


  def initialize(raw_data)
    self.raw = raw_data

    # terminal
    self.terminal = "T#{raw_data[0]}"

    # kind
    case raw_data[1]
    when "A"
      self.kind = "Arrivals"
    when "D"
      self.kind = "Departure"
    end

    # code
    self.code = raw_data[2]

    # code
    self.code_zh = raw_data[3]

    # flight
    self.flight = raw_data[4]

    # gate
    self.gate = raw_data[5]

    # datetime
    self.datetime = "#{raw_data[6]} #{raw_data[7]}"

    # expected_datetime
    self.expected_datetime = "#{raw_data[8]} #{raw_data[9]}"

    # destination
    self.destination = Destination.new(iata: raw_data[10], en: raw_data[11], zh: raw_data[12])

    # flight_status
    self.flight_status = raw_data[13]

    # aircraft_type
    self.aircraft_type = raw_data[14]

    # other_route
    self.other_route = Destination.new(iata: raw_data[15], en: raw_data[16], zh: raw_data[17])

    # baggage_carousel
    self.baggage_carousel = raw_data[18]

    # check_in_counter
    self.check_in_counter = raw_data[19]
  end
end


Version data entries

3 entries across 3 versions & 1 rubygems

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