Class: RateBeer::Brewery::BeerList
- Inherits:
-
Object
- Object
- RateBeer::Brewery::BeerList
- Defined in:
- lib/ratebeer/brewery/beer_list.rb
Overview
The BeerList class extracts a list of beers for a given brewery.
Constant Summary
Constants included from URLs
URLs::BASE_URL, URLs::SEARCH_URL
Instance Attribute Summary collapse
-
#brewery ⇒ Object
readonly
Returns the value of attribute brewery.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #beers ⇒ Object
-
#initialize(brewery) ⇒ BeerList
constructor
A new instance of BeerList.
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, #url
Constructor Details
#initialize(brewery) ⇒ BeerList
Returns a new instance of BeerList.
14 15 16 17 |
# File 'lib/ratebeer/brewery/beer_list.rb', line 14 def initialize(brewery) @brewery = brewery @id = brewery.id end |
Instance Attribute Details
#brewery ⇒ Object (readonly)
Returns the value of attribute brewery.
12 13 14 |
# File 'lib/ratebeer/brewery/beer_list.rb', line 12 def brewery @brewery end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/ratebeer/brewery/beer_list.rb', line 12 def id @id end |
Instance Method Details
#beers ⇒ Object
19 20 21 22 23 |
# File 'lib/ratebeer/brewery/beer_list.rb', line 19 def beers beers_doc = noko_doc(URI.join(BASE_URL, brewery_beers_url(id))) rows = beers_doc.css('table#brewer-beer-table tbody tr') @beers = rows.map { |row| process_beer_row(row) }.reject(&:nil?) end |