Class: WWFinder::City

Inherits:
Object
  • Object
show all
Defined in:
lib/ww_finder/city.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, url, country) ⇒ City

Returns a new instance of City.



7
8
9
10
11
12
13
# File 'lib/ww_finder/city.rb', line 7

def initialize(name, url, country)
    @name = name 
    @url = url
    @buildings = []
    set_country(country)
    save
end

Instance Attribute Details

#buildingsObject (readonly)

Returns the value of attribute buildings.



3
4
5
# File 'lib/ww_finder/city.rb', line 3

def buildings
  @buildings
end

#countryObject

Returns the value of attribute country.



2
3
4
# File 'lib/ww_finder/city.rb', line 2

def country
  @country
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/ww_finder/city.rb', line 2

def name
  @name
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/ww_finder/city.rb', line 2

def url
  @url
end

Class Method Details

.allObject



19
20
21
22
# File 'lib/ww_finder/city.rb', line 19

def self.all
    WWFinder::Scraper.scrape_cities if @@all.empty?
    @@all
end

.find(input) ⇒ Object



24
25
26
# File 'lib/ww_finder/city.rb', line 24

def self.find(input)
    all[input]
end

Instance Method Details

#get_buildingsObject



15
16
17
# File 'lib/ww_finder/city.rb', line 15

def get_buildings
    WWFinder::Scraper.scrape_buildings_for(self) if buildings.empty?
end