class WWFinder::City
Attributes
buildings[R]
country[RW]
name[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/ww_finder/city.rb, line 19 def self.all WWFinder::Scraper.scrape_cities if @@all.empty? @@all end
find(input)
click to toggle source
# File lib/ww_finder/city.rb, line 24 def self.find(input) all[input] end
new(name, url, country)
click to toggle source
# File lib/ww_finder/city.rb, line 7 def initialize(name, url, country) @name = name @url = url @buildings = [] set_country(country) save end
Public Instance Methods
get_buildings()
click to toggle source
# File lib/ww_finder/city.rb, line 15 def get_buildings WWFinder::Scraper.scrape_buildings_for(self) if buildings.empty? end
Private Instance Methods
save()
click to toggle source
# File lib/ww_finder/city.rb, line 29 def save @@all << self end
set_country(country)
click to toggle source
# File lib/ww_finder/city.rb, line 33 def set_country(country) @country = country country.cities << self end