Sha256: ea687bd59904df9676d8b228aba5e6cd7beed38f1243131105503612b59fc46e
Contents?: true
Size: 1017 Bytes
Versions: 16
Compression:
Stored size: 1017 Bytes
Contents
# frozen_string_literal: true require_relative 'airbnb_api' module Airbnb # Room info class RoomsInfo attr_reader :location attr_reader :rooms def initialize(location: nil) @location = location end def rooms return @rooms if @rooms rooms_data = AirbnbApi.rooms_result(@location) @rooms = rooms_data.map do |item| room(item) end end def self.find(location: nil) new(location: nil) end private def room(item) item = item { city: item['listing']['city'], name: item['listing']['name'], pic_url: item['listing']['picture_url'], id: item['listing']['id'], person_capacity: item['listing']['person_capacity'], primary_host: item['listing']['primary_host'], star_rating: item['listing']['star_rating'], listing_currency: item['pricing_quote']['listing_currency'], nightly_price: item['pricing_quote']['nightly_price'] } end end end
Version data entries
16 entries across 16 versions & 1 rubygems