lib/ratebeer/search.rb
def process_beers_table(table)
      beers = []
      threads = []
      mutex = Mutex.new
      table.css('tr').drop(1).map do |r|
        threads << Thread.new do
          beer = process_beer_row(r)
          mutex.synchronize { beers << beer }
        end
      end
      threads.each(&:join)
      beers
    end
# Process beers table returned in search.
#
# The beers table (if returned) consists of a series of rows each of which
# contains five cells: the first is the name (and hyperlink) to the beer;
# the second and third relate to features of the RateBeer.com site, and are
# ignored; the fourth provides the rating of the beer (if any); and the
# fifth contains the number of ratings submitted for this beer.
#
# The first row in the table contains headings, and is disregarded.
#
# @param [Nokogiri::XML::Element] table An HTML table containing beers
#   information
# @return [Hash{Symbol, String}] Beer data, including name, score, rating,
#   url and ID
#
Process beers table returned in search.
The beers table (if returned) consists of a series of rows each of which
contains five cells: the first is the name (and hyperlink) to the beer;
the second and third relate to features of the RateBeer.com site, and are
ignored; the fourth provides the rating of the beer (if any); and the
fifth contains the number of ratings submitted for this beer.

The first row in the table contains headings, and is disregarded.
Process beers table returned in search . The beers table ( if returned ) consists of a series of rows each of which contains five cells : the first is the name ( and hyperlink ) to the beer ; the second and third relate to features of the RateBeer . com site and are ignored ; the fourth provides the rating of the beer ( if any ) ; and the fifth contains the number of ratings submitted for this beer . The first row in the table contains headings and is disregarded .
def process_beers_table(table)
      beers = []
      threads = []
      mutex = Mutex.new
      table.css('tr').drop(1).map do |r|
        threads << Thread.new do
          beer = process_beer_row(r)
          mutex.synchronize { beers << beer }
        end
      end
      threads.each(&:join)
      beers
    end
def process_beers_table ( table ) beers = [ ] threads = [ ] mutex = Mutex . new table . css ( 'tr' ) . drop ( 1 ) . map do | r | threads << Thread . new do beer = process_beer_row ( r ) mutex . synchronize { beers << beer } end end threads . each ( & :join ) beers end
Process beers table returned in search.
Process beers table returned in search .
Beer data, including name, score, rating, url and ID
Beer data including name score rating url and ID
Hash{Symbol, String}
table
table An HTML table containing beers information
table An HTML table containing beers information