Class: HostConnect::AbstractResponse
- Inherits:
-
Object
- Object
- HostConnect::AbstractResponse
- Defined in:
- lib/hostconnect/response.rb
Overview
Abstract response class. Each subclass takes the XML responses and turns them into a basic datastructure, with each element available as an attribute.
Direct Known Subclasses
AddService, AgentInfo, GetBooking, GetBookingPaymentSummary, GetLocations, GetServices, GetSystemSettings, ListBookings, OptionInfo, Ping, RecordBookingPayment, SupplierInfo
Instance Method Summary collapse
-
#[](num) ⇒ Object
Act like an array.
-
#each ⇒ Object
Yields each element.
-
#elements ⇒ Object
Exposes the element-array of responses which consists of multiple elements.
-
#first ⇒ Object
Returns the first element.
-
#last ⇒ Object
Returns the last element.
Instance Method Details
#[](num) ⇒ Object
Act like an array
21 22 23 |
# File 'lib/hostconnect/response.rb', line 21 def [](num) elements[num] end |
#each ⇒ Object
Yields each element
6 7 8 |
# File 'lib/hostconnect/response.rb', line 6 def each elements.each { |e| yield e } end |
#elements ⇒ Object
Exposes the element-array of responses which consists of multiple elements. Raises an error if used on non-collection responses (Ping etc).
27 28 29 |
# File 'lib/hostconnect/response.rb', line 27 def elements (@elements.blank?) ? raise(ArgumentError, "Not a collection") : @elements end |
#first ⇒ Object
Returns the first element
11 12 13 |
# File 'lib/hostconnect/response.rb', line 11 def first elements.first end |
#last ⇒ Object
Returns the last element
16 17 18 |
# File 'lib/hostconnect/response.rb', line 16 def last elements.last end |