Sha256: a5cf0af727959db50151eec82b9fb1faed8a316eea51e66251ea7ad9ca0b12a0

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'open-uri'
require 'nokogiri'

api_request = Nokogiri::XML(open("http://beermapping.com/webservice/loccity/21110efff66df69d91ec3909c0a38eed/providence,ri"))
breweries = []
#we gotta use something called xpath?
api_request.xpath("//location").each do |location|
  brewery = {
    :id => location.xpath("child::id").text.to_i,
  :name => location.xpath("child::name").text,
  :street_address => location.xpath("child::street").text,
  :phone => location.xpath("child::phone").text
  }
  #add brewery to breweries
  breweries << brewery
  #puts "#{brewery}"
end

returned_scores = Nokogiri::HTML(open("http://beermapping.com/webservice/locscore/21110efff66df69d91ec3909c0a38eed/15566"))
#brewery score profile
score_location = returned_scores.xpath("//location")
score_profile = {
#overall_score, selection, service, atmosphere, food, review_count, fb_score, fb_count
  :overall_score => score_location.xpath("child::overall").text.to_f,
  :selection => score_location.xpath("child::selection").text.to_f,
  :service => score_location.xpath("child::service").text.to_f,
  :atmosphere => score_location.xpath("child::atmosphere").text.to_f,
  :review_count => score_location.xpath("child::reviewcount").text.to_f,
  :food=>score_location.xpath("child::food").text.to_f
  }
puts "#{returned_scores}"
puts"#{score_location}"
  puts "#{score_profile}"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Brew_Finder-0.1.1 api_query_tester.rb
Brew_Finder-0.1.0 api_query_tester.rb