Class: WWFinder::Country

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, continent) ⇒ Country



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

def initialize(name, continent)
    @name = name 
    @cities = []
    set_continent(continent)
    save
end

Instance Attribute Details

#citiesObject (readonly)

Returns the value of attribute cities.



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

def cities
  @cities
end

#continentObject

Returns the value of attribute continent.



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

def continent
  @continent
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.allObject



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

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

.find(input) ⇒ Object



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

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

Instance Method Details

#find_city(input) ⇒ Object



23
24
25
# File 'lib/ww_finder/country.rb', line 23

def find_city(input)
    cities[input]
end