Class: Yelp4r::Categories
- Inherits:
-
Object
- Object
- Yelp4r::Categories
- Defined in:
- lib/yelp4r/categories.rb
Instance Attribute Summary collapse
-
#parse_url ⇒ Object
Returns the value of attribute parse_url.
Instance Method Summary collapse
-
#initialize ⇒ Categories
constructor
A new instance of Categories.
- #list ⇒ Object
- #options_from_list(selected = []) ⇒ Object
Constructor Details
#initialize ⇒ Categories
Returns a new instance of Categories.
6 7 8 |
# File 'lib/yelp4r/categories.rb', line 6 def initialize @parse_url = "http://www.yelp.com/developers/documentation/category_list" end |
Instance Attribute Details
#parse_url ⇒ Object
Returns the value of attribute parse_url.
4 5 6 |
# File 'lib/yelp4r/categories.rb', line 4 def parse_url @parse_url end |
Instance Method Details
#list ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/yelp4r/categories.rb', line 10 def list require 'nokogiri' require 'open-uri' doc = Nokogiri::HTML(open(@parse_url)) html = doc.at("ul.attr-list") neighborhoods = process_list(html) return neighborhoods end |
#options_from_list(selected = []) ⇒ Object
19 20 21 22 |
# File 'lib/yelp4r/categories.rb', line 19 def (selected = []) selected_opts = selected.collect {|s| s.strip} (list, selected_opts) end |