class BeerList::Establishments::NewBohemia
Constants
- URL
Public Instance Methods
get_list()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 6 def get_list base_list strip end
url()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 11 def url URL end
Private Instance Methods
base_list()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 17 def base_list @beers = [left, right].inject([]) do |ary, collection| ary += match_before_slash(collection).compact end end
left()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 27 def left split_on_newline(left_column).flatten end
left_column()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 35 def left_column page.search('div.col-left p').map(&:text) end
match_before_slash(beers)
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 47 def match_before_slash(beers) beers.map{ |beer| beer.match(/\A([^\/]+)\/{1}/); $1 } end
right()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 31 def right right_column end
right_column()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 39 def right_column page.search('div.col-right p span').map(&:text) end
split_on_newline(beers)
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 43 def split_on_newline(beers) beers.inject([]) { |ary, string| ary << string.split("\n") } end
strip()
click to toggle source
# File lib/beer_list/establishments/new_bohemia.rb, line 23 def strip @beers = @beers.map{ |beer| beer.gsub(/\A\W*|\W*\z/, '') } end