Class: Iso3166Ru::CountryList
- Inherits:
-
Object
- Object
- Iso3166Ru::CountryList
- Defined in:
- lib/iso3166_ru/country_list.rb
Instance Attribute Summary collapse
-
#countries ⇒ Object
readonly
Returns the value of attribute countries.
Instance Method Summary collapse
- #find_by(source_query) ⇒ Object
-
#initialize ⇒ CountryList
constructor
A new instance of CountryList.
Constructor Details
#initialize ⇒ CountryList
Returns a new instance of CountryList.
7 8 9 10 11 |
# File 'lib/iso3166_ru/country_list.rb', line 7 def initialize File.open(File.("../data.dat", __FILE__)) do |f| @countries = Marshal.load(f) end end |
Instance Attribute Details
#countries ⇒ Object (readonly)
Returns the value of attribute countries.
5 6 7 |
# File 'lib/iso3166_ru/country_list.rb', line 5 def countries @countries end |
Instance Method Details
#find_by(source_query) ⇒ Object
13 14 15 16 |
# File 'lib/iso3166_ru/country_list.rb', line 13 def find_by(source_query) query = source_query.to_a.flatten countries.select { |e| e.send(query[0]) == query[1] }.first end |