lib/ratebeer/style.rb
def all_styles(include_hidden = false)
        doc  = Scraping.noko_doc(URI.join(BASE_URL, '/beerstyles/'))
        root = doc.at_css('div.container-fluid')

        categories = root.css('h3').map(&:text)
        style_node = root.css('.styleGroup')

        styles = style_node.flat_map.with_index do |list, i|
          list.css('a').map do |x|
            category = categories[i]
            Style.new(x['href'].split('/').last.to_i, name: x.text).tap do |s|
              s.category = category
            end
          end
        end
        if include_hidden
          styles + hidden_styles
        else
          styles
        end
      end
# Scrape all styles.
#
# RateBeer provides a styles landing page, with links through to info on
# each style listed thereon. This method scrapes style info with links
# to the more detailed pages.
#
# @param [Boolean] hidden_styles Flag for whether to include hidden
#   styles.
# @return [Array<RateBeer::Style>] List of styles with links etc. to
#   detailed pages
#
Scrape all styles.
RateBeer provides a styles landing page, with links through to info on
each style listed thereon. This method scrapes style info with links
to the more detailed pages.
Scrape all styles . RateBeer provides a styles landing page with links through to info on each style listed thereon . This method scrapes style info with links to the more detailed pages .
def all_styles(include_hidden = false)
        doc  = Scraping.noko_doc(URI.join(BASE_URL, '/beerstyles/'))
        root = doc.at_css('div.container-fluid')
        categories = root.css('h3').map(&:text)
        style_node = root.css('.styleGroup')
        styles = style_node.flat_map.with_index do |list, i|
          list.css('a').map do |x|
            category = categories[i]
            Style.new(x['href'].split('/').last.to_i, name: x.text).tap do |s|
              s.category = category
            end
          end
        end
        if include_hidden
          styles + hidden_styles
        else
          styles
        end
      end
def all_styles ( include_hidden = false ) doc = Scraping . noko_doc ( URI . join ( BASE_URL , '/beerstyles/' ) ) root = doc . at_css ( 'div.container-fluid' ) categories = root . css ( 'h3' ) . map ( & :text ) style_node = root . css ( '.styleGroup' ) styles = style_node . flat_map . with_index do | list , i | list . css ( 'a' ) . map do | x | category = categories [ i ] Style . new ( x [ 'href' ] . split ( '/' ) . last . to_i , name : x . text ) . tap do | s | s . category = category end end end if include_hidden styles + hidden_styles else styles end end
Scrape all styles.
Scrape all styles .
List of styles with links etc. to detailed pages
List of styles with links etc . to detailed pages
Array<RateBeer::Style>
include_hidden
hidden_styles Flag for whether to include hidden styles.
hidden_styles Flag for whether to include hidden styles .