Sha256: 45b3c73b3191714b46b882a7e08e40af5b268a2fd0c9552f37ee7cb931c09206
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
require 'rest-client' require 'lita-onewheel-beer-base' require 'json' module Lita module Handlers class OnewheelBeerUntappdLib < OnewheelBeerBase # This is the worker bee- decoding the html into our "standard" document. # Future implementations could simply override this implementation-specific # code to help this grow more widely. def parse_response(response) Lita.logger.debug 'parse_response started.' gimme_what_you_got = {} noko = Nokogiri.HTML response noko.css('div.beer-details').each do |beer_node| # beer_node = beer_node.css('div#section_217106141') name_n_tap = beer_node.css('h5 a').first.children.to_s short_desc = beer_node.css('h5 em').first.children.to_s brewery = beer_node.css('h6 a').first.children.to_s abv_node = beer_node.css('h6 span').first.children.to_s # Lita.logger.info("NnT: #{name_n_tap}") /^(?<tap>\d)\.\s*(?<beer_name>.*)/ =~ name_n_tap # tap = name_n_tap[/^\d+/] next if tap.nil? # print "name_n_tap #{name_n_tap}" # beer_name = name_n_tap[/[^\..]+$/].strip abv = abv_node[/^\d+\.\d+/] beer_desc = short_desc # full_text_search = "#{tap.sub /\d+/, ''} #{brewery} #{beer_name} #{beer_desc.to_s.gsub /\d+\.*\d*%*/, ''}" # prices = get_prices(beer_node) gimme_what_you_got[tap] = { # type: tap_type, # remaining: remaining, brewery: brewery.to_s, name: beer_name.to_s, desc: beer_desc.to_s, abv: abv.to_f # prices: prices, # price: prices[1][:cost], # search: full_text_search } end gimme_what_you_got end Lita.register_handler(self) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-onewheel-beer-untappd-lib-0.0.0 | lib/lita/handlers/onewheel_beer_untappd_lib.rb |