class Fifa
note: use class for now - change to module - possible? - why? why not?
Constants
- ALT_ORG_NAMES
- MAJOR
- MINOR
- PATCH
- VERSION
Public Class Methods
[]( key )
click to toggle source
# File lib/fifa.rb, line 16 def self.[]( key ) country_index[ key ]; end
countries()
click to toggle source
# File lib/fifa.rb, line 15 def self.countries() country_index.countries; end
data_dir()
click to toggle source
# File lib/fifa/version.rb, line 24 def self.data_dir ## rename to config_dir - why? why not? "#{root}/config" end
members( key=:fifa )
click to toggle source
# File lib/fifa.rb, line 44 def self.members( key=:fifa ) ## default to fifa members key = key.to_s.downcase countries = org_index[ key ] if countries.nil? ## (re)try / check with alternative (convenience) org name alt_key = ALT_ORG_NAMES[ normalize_org( key ) ] countries = org_index[ alt_key ] if alt_key end countries end
normalize_org( name )
click to toggle source
# File lib/fifa.rb, line 55 def self.normalize_org( name ) ## remove space, comma, ampersand (&) and words: and, the name.gsub( /[ ,&]|\band\b|\bthe\b/, '' ) end
orgs()
click to toggle source
# File lib/fifa.rb, line 61 def self.orgs() org_index.keys; end
root()
click to toggle source
# File lib/fifa/version.rb, line 20 def self.root File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) ) end
version()
click to toggle source
# File lib/fifa/version.rb, line 12 def self.version VERSION end
Private Class Methods
build_country_index()
click to toggle source
# File lib/fifa.rb, line 69 def self.build_country_index recs = SportDb::Import::CountryReader.read( "#{Fifa.data_dir}/countries.txt" ) CountryIndex.new( recs ) end
build_org_index()
click to toggle source
# File lib/fifa.rb, line 79 def self.build_org_index orgs = {} countries.each do |country| ## note: assumes all tags are sport / fifa tags for now country.tags.each do |tag| orgs[ tag ] ||= [] orgs[ tag ] << country end end orgs end
country_index()
click to toggle source
# File lib/fifa.rb, line 65 def self.country_index @country_index ||= build_country_index end
org_index()
click to toggle source
# File lib/fifa.rb, line 75 def self.org_index @org_index ||= build_org_index ## fifa, uefa, etc. end