class RealPage::DocumentParser::GuestCards::Amenities

Parse the Amenities from a GuestCards response. RealPage spells everything “amentities”, so we also correct for that.

Public Instance Methods

parse(amenities_hash) click to toggle source

@param amenities_hash [Array<Hash<String, Object>>] an 'Amentities'

entry of the XML response parsed into a Hash

@return [Array<RealPage::Model::Amenity>] the amenities contained

in this amenities_hash

@raise [RealPage::Error::Base] if the response is invalid

# File lib/real_page/document_parser/guest_cards/amenities.rb, line 16
def parse(amenities_hash)
  amenities(amenities_hash).map do |amenity|
    attrs = amenity.dup
    # RealPage spells AmenityID wrong
    attrs['AmenityID'] = attrs.delete('AmentityID')
    Model::Amenity.new(attrs)
  end
end

Private Instance Methods

amenities(amenities_hash) click to toggle source
# File lib/real_page/document_parser/guest_cards/amenities.rb, line 27
def amenities(amenities_hash)
  #R RealPage spells the Amenity tag wrong
  Utils::ArrayFetcher.new(hash: amenities_hash, key: 'Amentity').fetch
end