Class: Asdawqw::Restriction
- Defined in:
- lib/asdawqw/models/restriction.rb
Overview
Restriction Model.
Instance Attribute Summary collapse
-
#begin_date ⇒ Date
Beginning date of date range for which restriction is applied.
-
#check_in ⇒ CheckIn
Object.
-
#check_out ⇒ CheckOut
Object.
-
#end_date ⇒ Date
End date of date range for which restriction is applied.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(begin_date = nil, end_date = nil, check_in = nil, check_out = nil) ⇒ Restriction
constructor
A new instance of Restriction.
Methods inherited from BaseModel
Constructor Details
#initialize(begin_date = nil, end_date = nil, check_in = nil, check_out = nil) ⇒ Restriction
Returns a new instance of Restriction.
37 38 39 40 41 42 43 44 45 |
# File 'lib/asdawqw/models/restriction.rb', line 37 def initialize(begin_date = nil, end_date = nil, check_in = nil, check_out = nil) @begin_date = begin_date @end_date = end_date @check_in = check_in @check_out = check_out end |
Instance Attribute Details
#begin_date ⇒ Date
Beginning date of date range for which restriction is applied. Date should be in format “yyyy-MM-dd”
12 13 14 |
# File 'lib/asdawqw/models/restriction.rb', line 12 def begin_date @begin_date end |
#check_in ⇒ CheckIn
Object
21 22 23 |
# File 'lib/asdawqw/models/restriction.rb', line 21 def check_in @check_in end |
#check_out ⇒ CheckOut
Object
25 26 27 |
# File 'lib/asdawqw/models/restriction.rb', line 25 def check_out @check_out end |
#end_date ⇒ Date
End date of date range for which restriction is applied. Date should be in format “yyyy-MM-dd”
17 18 19 |
# File 'lib/asdawqw/models/restriction.rb', line 17 def end_date @end_date end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/asdawqw/models/restriction.rb', line 48 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. begin_date = hash['beginDate'] end_date = hash['endDate'] check_in = CheckIn.from_hash(hash['checkIn']) if hash['checkIn'] check_out = CheckOut.from_hash(hash['checkOut']) if hash['checkOut'] # Create object from extracted values. Restriction.new(begin_date, end_date, check_in, check_out) end |
.names ⇒ Object
A mapping from model property names to API property names.
28 29 30 31 32 33 34 35 |
# File 'lib/asdawqw/models/restriction.rb', line 28 def self.names @_hash = {} if @_hash.nil? @_hash['begin_date'] = 'beginDate' @_hash['end_date'] = 'endDate' @_hash['check_in'] = 'checkIn' @_hash['check_out'] = 'checkOut' @_hash end |