class BeerList::Establishments::BustersOn28th

Constants

URL

Public Instance Methods

get_list() click to toggle source
# File lib/beer_list/establishments/busters_on28th.rb, line 6
def get_list
  base_list
  split_on_newline
  reject_headers
  match_pre_vol
  reject_nils
end
url() click to toggle source
# File lib/beer_list/establishments/busters_on28th.rb, line 14
def url
  URL
end

Private Instance Methods

base_list() click to toggle source
# File lib/beer_list/establishments/busters_on28th.rb, line 20
def base_list
  @busters = page.search('p').map(&:text)
end
match_pre_vol() click to toggle source
# File lib/beer_list/establishments/busters_on28th.rb, line 43
def match_pre_vol
  @busters = @busters.map do |beer|
    beer.match(/\d{1,2}\.?\d*\s*oz/) ? $`.strip : nil
  end
end
reject_headers() click to toggle source

First, select all entries that have a lowercase letter (headers do not) At that point, there are still some headers mixed with beer names. For example:

STOUTSurly Darkness

Match group 3 or more capital letters followed by one cap and one lower take the portion of the beer name after the match group

# File lib/beer_list/establishments/busters_on28th.rb, line 36
def reject_headers
  @busters = @busters.select{ |beer| beer.match /[a-z]/ }
  @busters = @busters.map do |beer|
    beer.match(/([A-Z]{3,})[A-Z]{1}[a-z]{1}/) ? beer.split($1).last : beer
  end
end
reject_nils() click to toggle source
# File lib/beer_list/establishments/busters_on28th.rb, line 49
def reject_nils
  @busters = @busters.reject(&:nil?)
end
split_on_newline() click to toggle source
# File lib/beer_list/establishments/busters_on28th.rb, line 24
def split_on_newline
  @busters = @busters.map{ |beer| beer.split("\n") }.flatten
end