Class: BorrowDirect::PickupLocation
- Inherits:
-
Object
- Object
- BorrowDirect::PickupLocation
- Defined in:
- lib/borrow_direct/pickup_location.rb
Overview
Returned from FindItem::Response.pickup_locations , contains a #code and a #description . #to_a returns a handy duple suitable for passing to Rails options_for_select
Instance Attribute Summary collapse
-
#response_hash ⇒ Object
readonly
Returns the value of attribute response_hash.
Instance Method Summary collapse
- #code ⇒ Object
- #description ⇒ Object
-
#initialize(bd_hash) ⇒ PickupLocation
constructor
A new instance of PickupLocation.
-
#to_a ⇒ Object
Handy for passing to Rails options_for_select.
- #to_h ⇒ Object
Constructor Details
#initialize(bd_hash) ⇒ PickupLocation
Returns a new instance of PickupLocation.
7 8 9 10 11 12 13 |
# File 'lib/borrow_direct/pickup_location.rb', line 7 def initialize(bd_hash) if bd_hash["PickupLocationCode"].empty? || bd_hash["PickupLocationDescription"].empty? raise ArgumentError, "PickupLocation requires a hash with PickupLocationCode and PickupLocationDescription, not `#{bd_hash}`" end @response_hash = bd_hash end |
Instance Attribute Details
#response_hash ⇒ Object (readonly)
Returns the value of attribute response_hash.
6 7 8 |
# File 'lib/borrow_direct/pickup_location.rb', line 6 def response_hash @response_hash end |
Instance Method Details
#code ⇒ Object
15 16 17 |
# File 'lib/borrow_direct/pickup_location.rb', line 15 def code @response_hash["PickupLocationCode"] end |
#description ⇒ Object
19 20 21 |
# File 'lib/borrow_direct/pickup_location.rb', line 19 def description @response_hash["PickupLocationDescription"] end |
#to_a ⇒ Object
Handy for passing to Rails options_for_select
28 29 30 |
# File 'lib/borrow_direct/pickup_location.rb', line 28 def to_a [self.description, self.code] end |
#to_h ⇒ Object
23 24 25 |
# File 'lib/borrow_direct/pickup_location.rb', line 23 def to_h self.response_hash end |