Class: TripIt::CruiseObject
- Inherits:
-
ReservationObject
- Object
- Base
- BaseObject
- ReservationObject
- TripIt::CruiseObject
- Defined in:
- lib/trip_it/classes/objects/cruise_object.rb
Instance Attribute Summary
Attributes inherited from BaseObject
#id, #is_client_traveler, #relative_url
Instance Method Summary collapse
-
#initialize(client, obj_id = nil, source = nil) ⇒ CruiseObject
constructor
A new instance of CruiseObject.
- #populate(source) ⇒ Object
- #segment ⇒ Object
- #segment=(val) ⇒ Object
- #sequence ⇒ Object
Methods inherited from BaseObject
Methods inherited from Base
#Boolean, #camelize, #chkAndPopulate, #chkObjAndPopulate, #convertDT, #to_hash, #to_json, #to_xml
Methods included from ParamUtil
#address_param, #airportcode_param, #array_param, #boolean_param, #boolean_read_param, #camelize, #date_param, #datetime_param, #exceptions, #float_param, #integer_param, #string_param, #time_param, #traveler_array_param, #traveler_param
Constructor Details
#initialize(client, obj_id = nil, source = nil) ⇒ CruiseObject
Returns a new instance of CruiseObject.
6 7 8 9 10 11 12 |
# File 'lib/trip_it/classes/objects/cruise_object.rb', line 6 def initialize(client, obj_id = nil, source = nil) @client = client unless obj_id.nil? @obj_id = obj_id populate(source) end end |
Instance Method Details
#populate(source) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trip_it/classes/objects/cruise_object.rb', line 14 def populate(source) info = source || @client.get("/cruise", :id => @obj_id)["CruiseObject"] super(info) @segment = [] @traveler = [] @cabin_number = info["cabin_number"] @cabin_type = info["cabin_type"] @dining = info["dining"] @ship_name = info["ship_name"] chkAndPopulate(@segment, TripIt::CruiseSegment, info["Segment"]) chkAndPopulate(@traveler, TripIt::Traveler, info["Traveler"]) end |
#segment ⇒ Object
27 28 29 |
# File 'lib/trip_it/classes/objects/cruise_object.rb', line 27 def segment @segment end |
#segment=(val) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/trip_it/classes/objects/cruise_object.rb', line 30 def segment=(val) if val.is_a?(Array) && val.all? { |e| CruiseSegment === e } @segment = val else raise ArgumentError, "Segment must be an Array of CruiseSegments" end end |
#sequence ⇒ Object
38 39 40 41 |
# File 'lib/trip_it/classes/objects/cruise_object.rb', line 38 def sequence arr = super arr + ["@segment", "@traveler", "@cabin_number", "@cabin_type", "@dining", "@ship_name"] end |