Class: RateBeer::Location
- Inherits:
-
Object
- Object
- RateBeer::Location
- Defined in:
- lib/ratebeer/location.rb
Constant Summary
Constants included from URLs
URLs::BASE_URL, URLs::SEARCH_URL
Instance Attribute Summary
Attributes included from Scraping
Class Method Summary collapse
-
.data_keys ⇒ Object
Keys for fields scraped on RateBeer.
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(id, location_type: nil, name: nil, **options) ⇒ Location
constructor
Initialize a RateBeer::Location instance.
Methods included from URLs
#beer_url, #brewery_beers_url, #brewery_url, #country_url, #region_url, #review_url, #style_beers_url, #style_url
Methods included from Scraping
#==, #fix_characters, #full_details, #id_from_link, included, #inspect, nbsp, noko_doc, #page_count, #pagination?, #post_request, #symbolize_text, #to_s
Constructor Details
#initialize(id, location_type: nil, name: nil, **options) ⇒ Location
Initialize a RateBeer::Location instance.
Locations may be either Regions or Countries. This must be specified to the constructor.
26 27 28 29 30 31 32 33 |
# File 'lib/ratebeer/location.rb', line 26 def initialize(id, location_type: nil, name: nil, **) super if location_type.nil? || ![:country, :region].include?(location_type) raise ArgumentError.new('location_type must be supplied and must be '\ 'either country or region') end @location_type = location_type end |
Class Method Details
.data_keys ⇒ Object
Keys for fields scraped on RateBeer
8 9 10 11 12 |
# File 'lib/ratebeer/location.rb', line 8 def self.data_keys [:name, :num_breweries, :breweries] end |
Instance Method Details
#doc ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ratebeer/location.rb', line 35 def doc unless instance_variable_defined?('@doc') @doc = noko_doc(url) validate_location end @doc end |