Class: KondutoTravelInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/konduto-ruby/konduto_travel_info.rb

Constant Summary collapse

TRAVEL_CLASS =
[:economy, :business, :first]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ KondutoTravelInfo

Returns a new instance of KondutoTravelInfo.


6
7
8
9
10
11
12
# File 'lib/konduto-ruby/konduto_travel_info.rb', line 6

def initialize(*args)
  unless args[0].nil?
    args[0].each do |k,v|
      instance_variable_set("@#{k}", v) unless v.nil?
    end
  end
end

Instance Attribute Details

#classObject

Returns the value of attribute class


2
3
4
# File 'lib/konduto-ruby/konduto_travel_info.rb', line 2

def class
  @class
end

#dateObject

Returns the value of attribute date


2
3
4
# File 'lib/konduto-ruby/konduto_travel_info.rb', line 2

def date
  @date
end

#fare_basisObject

Returns the value of attribute fare_basis


2
3
4
# File 'lib/konduto-ruby/konduto_travel_info.rb', line 2

def fare_basis
  @fare_basis
end

#number_of_connectionsObject

Returns the value of attribute number_of_connections


2
3
4
# File 'lib/konduto-ruby/konduto_travel_info.rb', line 2

def number_of_connections
  @number_of_connections
end

Instance Method Details

#to_hashObject


14
15
16
17
18
19
20
21
22
# File 'lib/konduto-ruby/konduto_travel_info.rb', line 14

def to_hash
  hash = {
      date: self.date,
      number_of_connections: self.number_of_connections,
      class: self.class,
      fare_basis: self.fare_basis
  }
  KondutoUtils.remove_nil_keys_from_hash(hash)
end

#to_jsonObject


24
25
26
# File 'lib/konduto-ruby/konduto_travel_info.rb', line 24

def to_json
  self.to_hash.to_json
end