Class: WWFinder::Country
- Inherits:
-
Object
- Object
- WWFinder::Country
- Defined in:
- lib/ww_finder/country.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#cities ⇒ Object
readonly
Returns the value of attribute cities.
-
#continent ⇒ Object
Returns the value of attribute continent.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #find_city(input) ⇒ Object
-
#initialize(name, continent) ⇒ Country
constructor
A new instance of Country.
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
#cities ⇒ Object (readonly)
Returns the value of attribute cities.
3 4 5 |
# File 'lib/ww_finder/country.rb', line 3 def cities @cities end |
#continent ⇒ Object
Returns the value of attribute continent.
2 3 4 |
# File 'lib/ww_finder/country.rb', line 2 def continent @continent end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/ww_finder/country.rb', line 2 def name @name end |
Class Method Details
.all ⇒ Object
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 |