class WWFinder::Country
Attributes
cities[R]
continent[RW]
name[RW]
Public Class Methods
all()
click to toggle source
# File lib/ww_finder/country.rb, line 14 def self.all WWFinder::Scraper.scrape_countries if @@all.empty? @@all end
find(input)
click to toggle source
# File lib/ww_finder/country.rb, line 19 def self.find(input) all[input] end
new(name, continent)
click to toggle source
# File lib/ww_finder/country.rb, line 7 def initialize(name, continent) @name = name @cities = [] set_continent(continent) save end
Public Instance Methods
find_city(input)
click to toggle source
# File lib/ww_finder/country.rb, line 23 def find_city(input) cities[input] end
Private Instance Methods
save()
click to toggle source
# File lib/ww_finder/country.rb, line 28 def save @@all << self end
set_continent(cont)
click to toggle source
# File lib/ww_finder/country.rb, line 32 def set_continent(cont) @continent = cont continent.countries << self end