Class: KondutoPassenger
- Inherits:
-
Object
- Object
- KondutoPassenger
- Defined in:
- lib/konduto-ruby/konduto_passenger.rb
Constant Summary collapse
- TYPE_DOCUMENT =
[:passport, :id]
Instance Attribute Summary collapse
-
#dob ⇒ Object
Returns the value of attribute dob.
-
#document ⇒ Object
Returns the value of attribute document.
-
#document_type ⇒ Object
Returns the value of attribute document_type.
-
#frequent_traveller ⇒ Object
Returns the value of attribute frequent_traveller.
-
#loyalty ⇒ Object
Returns the value of attribute loyalty.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nationality ⇒ Object
Returns the value of attribute nationality.
-
#special_needs ⇒ Object
Returns the value of attribute special_needs.
Instance Method Summary collapse
-
#initialize(*args) ⇒ KondutoPassenger
constructor
A new instance of KondutoPassenger.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(*args) ⇒ KondutoPassenger
Returns a new instance of KondutoPassenger.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 7 def initialize(*args) if args[0].nil? self.loyalty = KondutoLoyalty.new else if args[0][:loyalty].nil? self.loyalty = KondutoLoyalty.new else self.loyalty = KondutoLoyalty.new args[0][:loyalty] args[0].delete :loyalty end args[0].each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end end |
Instance Attribute Details
#dob ⇒ Object
Returns the value of attribute dob.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def dob @dob end |
#document ⇒ Object
Returns the value of attribute document.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def document @document end |
#document_type ⇒ Object
Returns the value of attribute document_type.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def document_type @document_type end |
#frequent_traveller ⇒ Object
Returns the value of attribute frequent_traveller.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def frequent_traveller @frequent_traveller end |
#loyalty ⇒ Object
Returns the value of attribute loyalty.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def loyalty @loyalty end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def name @name end |
#nationality ⇒ Object
Returns the value of attribute nationality.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def nationality @nationality end |
#special_needs ⇒ Object
Returns the value of attribute special_needs.
4 5 6 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4 def special_needs @special_needs end |
Instance Method Details
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 23 def to_hash hash = { name: self.name, document: self.document, document_type: self.document_type, dob: self.dob, nationality: self.nationality, frequent_traveller: self.frequent_traveller, special_needs: self.special_needs, loyalty: self.loyalty.to_hash } KondutoUtils.remove_nil_keys_from_hash(hash) end |
#to_json ⇒ Object
37 38 39 |
# File 'lib/konduto-ruby/konduto_passenger.rb', line 37 def to_json self.to_hash.to_json end |