Class: Fifa

Inherits:
Object
  • Object
show all
Defined in:
lib/fifa/version.rb,
lib/fifa.rb,
lib/fifa/countries.rb

Overview

note: use class for now - change to module - possible? - why? why not?

Defined Under Namespace

Classes: CountryIndex

Constant Summary collapse

ALT_ORG_NAMES =
{
  'world'  => 'fifa',
  'europe' => 'uefa',    #=> Union of European Football Associations
  'northamericacentralamericacaribbean' => 'concacaf',  #=> Confederation of North, Central American and Caribbean Association Football
  'northcentralamericacaribbean'        => 'concacaf',  ## e.g. North & Central America and the Caribbean
  'northamerica' => 'nafu',  # => North American Football Union
  'centralamerica' => 'uncaf',  #=> Unión Centroamericana de Fútbol
  'caribbean' => 'cfu',  #=> Caribbean Football Union
  'africa' => 'caf',      # => Confédération Africaine de Football
  'eastcentralafrica' => 'cecafa',  # => Council for East and Central Africa Football Associations
  'southernafrica' => 'cosafa',   # => Council of Southern Africa Football Associations
  'westafrica' => 'wafu',         # => West African Football Union/Union du Football de l'Ouest Afrique
  'northafrica' => 'unaf',        # => Union of North African Federations
  'centralafrica' => 'uniffac',  # => Union des Fédérations du Football de l'Afrique Centrale
  'asia'   => 'afc',      # => Asian Football Confederation
  'middleeast' => 'waff', # => West Asian Football Federation  -- note: excludes Iran and Israel
  'eastasia'   => 'eaff',
  'centralasia' => 'cafa',
  'southasia' => 'saff',
  'southeastasia' => 'aff',
  'oceania'    => 'ofc',  # =>  Oceania Football Confederation
  'pacific'    => 'ofc',
  'southamerica' => 'conmebol',  #=>  Confederación Sudamericana de Fútbol
}
MAJOR =

todo: namespace inside version or something - why? why not??

2020
MINOR =
9
PATCH =
15
VERSION =
[MAJOR,MINOR,PATCH].join('.')

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



16
# File 'lib/fifa.rb', line 16

def self.[]( key )   country_index[ key ]; end


16
17
18
# File 'lib/fifa/version.rb', line 16

def self.banner
  "fifa/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
end

.countriesObject

return all country (struct-like) records



15
# File 'lib/fifa.rb', line 15

def self.countries() country_index.countries; end

.data_dirObject

rename to config_dir - why? why not?



24
25
26
# File 'lib/fifa/version.rb', line 24

def self.data_dir  ## rename to config_dir - why? why not?
  "#{root}/config"
end

.members(key = :fifa) ⇒ Object

default to fifa members



44
45
46
47
48
49
50
51
52
53
# 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) ⇒ Object



55
56
57
58
# 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

.orgsObject

return list of known org (keys) e.g. fifa, uefa, etc.



61
# File 'lib/fifa.rb', line 61

def self.orgs()  org_index.keys; end

.rootObject



20
21
22
# File 'lib/fifa/version.rb', line 20

def self.root
  File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
end

.versionObject



12
13
14
# File 'lib/fifa/version.rb', line 12

def self.version
  VERSION
end