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

Version Path
movlog-0.3.1 lib/movlog/room.rb
movlog-0.3.0 lib/movlog/room.rb
movlog-0.2.12 lib/movlog/room.rb
movlog-0.2.11 lib/movlog/room.rb
movlog-0.2.10 lib/movlog/room.rb
movlog-0.2.9 lib/movlog/room.rb
movlog-0.2.8 lib/movlog/room.rb
movlog-0.2.7 lib/movlog/room.rb
movlog-0.2.6 lib/movlog/room.rb
movlog-0.2.5 lib/movlog/room.rb
movlog-0.2.4 lib/movlog/room.rb
movlog-0.2.3 lib/movlog/room.rb
movlog-0.2.2 lib/movlog/room.rb
movlog-0.2.1 lib/movlog/room.rb
movlog-0.2.0 lib/movlog/room.rb
movlog-0.1.0 lib/movlog/room.rb