Class: WWFinder::Continent

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Continent

Returns a new instance of Continent.



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

def initialize(name)
    @name = name 
    @countries = []
    save
end

Instance Attribute Details

#countriesObject (readonly)

Returns the value of attribute countries.



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

def countries
  @countries
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.allObject



13
14
15
16
# File 'lib/ww_finder/continent.rb', line 13

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

.find(input) ⇒ Object



18
19
20
# File 'lib/ww_finder/continent.rb', line 18

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

Instance Method Details

#find_country(input) ⇒ Object



22
23
24
# File 'lib/ww_finder/continent.rb', line 22

def find_country(input)
    countries[input]
end