Class: Yelp4r::Neighborhoods

Inherits:
Object
  • Object
show all
Defined in:
lib/yelp4r/neighborhoods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNeighborhoods

Returns a new instance of Neighborhoods.



6
7
8
# File 'lib/yelp4r/neighborhoods.rb', line 6

def initialize
  @parse_url = "http://www.yelp.com/developers/documentation/neighborhood_list"
end

Instance Attribute Details

#parse_urlObject

Returns the value of attribute parse_url.



4
5
6
# File 'lib/yelp4r/neighborhoods.rb', line 4

def parse_url
  @parse_url
end

Instance Method Details

#listObject



10
11
12
13
14
15
16
17
# File 'lib/yelp4r/neighborhoods.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/neighborhoods.rb', line 19

def options_from_list(selected = [])
  selected_opts = selected.collect {|s| s.strip}
  process_options(list, selected_opts)
end