Module: YUniversity

Defined in:
lib/yuniversity.rb,
lib/yuniversity/version.rb

Constant Summary collapse

RAW =
YAML.load_file(File.join(File.dirname(__FILE__), 'YUniversity', 'data', 'universities.yml'))
ALL =
RAW.map{|c| c['schools']}.flatten
COUNTRIES =
RAW.map{|c| {name: c['name'], code: c['iso_code']}}.flatten
COUNTRY_NAMES =
RAW.map{|c| c['name']}.flatten
NAMES =
ALL.map{|u| u['name']}
VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.find_by_countries(countries) ⇒ Object



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

def self.find_by_countries(countries)
  ALL.select{|c| countries.map{|e| e.downcase }.include?(c['country'].downcase)}
end

.find_by_country(country) ⇒ Object



15
16
17
# File 'lib/yuniversity.rb', line 15

def self.find_by_country(country)
  ALL.select{|c| c['country'].downcase.match(country.downcase)}
end

.find_country_by_university(university) ⇒ Object



23
24
25
26
# File 'lib/yuniversity.rb', line 23

def self.find_country_by_university(university)
  university = ALL.find{|c| c['name'].downcase.match(university.downcase)}
  university['country'] unless university.nil?
end