Top Level Namespace

Defined Under Namespace

Modules: CatalogDb, SportDb

Instance Method Summary collapse

Instance Method Details

#find_countries_for_league(league) ⇒ Object

global helpers

  find a better name/place in module(s) or such

what name to use?
  find_countries_for_league_clubs or such
   find_countries_for_league  - why? why not?
   note -  returns array of countries OR single country


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/sportdb/catalogs.rb', line 88

def find_countries_for_league( league )
    ## todo/fix: assert league is a League with country record/struct !!!!!

    countries = []
    countries << league.country   ### assume league.country is already db record/struct - why? why not?
    ## check for 2nd countries for known leagues
    ## (re)try with second country - quick hacks for known leagues
    ##  e.g. Swanse, cardiff  in premier league
    ##       san mariono in serie a (italy)
    ##       monaco  in ligue 1 (france)
    ##       etc.
    ##   add  andorra to spanish la liga (e.g. andorra fc???)

    case league.country.key
    when 'eng' then countries << CatalogDb::Metal::Country._record('wal')
    when 'sco' then countries << CatalogDb::Metal::Country._record('eng')
    when 'ie'  then countries << CatalogDb::Metal::Country._record('nir')
    when 'fr'  then countries << CatalogDb::Metal::Country._record('mc')
    when 'es'  then countries << CatalogDb::Metal::Country._record('ad')
    when 'it'  then countries << CatalogDb::Metal::Country._record('sm')
    when 'ch'  then countries << CatalogDb::Metal::Country._record('li')
    when 'us'  then countries << CatalogDb::Metal::Country._record('ca')
    when 'au'  then countries << CatalogDb::Metal::Country._record('nz')
    end

    ## use single ("unwrapped") item for one country
    ##    otherwise use array
    country =  countries.size == 1 ? countries[0] : countries
    country
end