Sha256: 6ea58e87bd4131c3a832f8620072ab20cbe96c9d48dfaa7a1eaa1f33066d0944
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
# encoding: utf-8 module SportDb module Import class League attr_reader :key, :name, :country, :intl attr_accessor :alt_names ## special import only attribs attr_accessor :alt_names_auto ## auto-generated alt names def initialize( key:, name:, alt_names: [], alt_names_auto: [], country: nil, intl: false ) @key = key @name = name @alt_names = alt_names @alt_names_auto = alt_names_auto @country = country @intl = intl end def intl?() @intl == true; end def national?() @intl == false; end alias_method :domestic?, :national? ## todo/fix: (re)use helpers from clubs - how? why? why not? LANG_REGEX = /\[[a-z]{1,2}\]/ ## note also allow [a] or [d] or [e] - why? why not? def self.strip_lang( name ) name.gsub( LANG_REGEX, '' ).strip end NORM_REGEX = /[.'º\-\/]/ ## note: remove all dots (.), dash (-), ', º, /, etc. ## for norm(alizing) names def self.strip_norm( name ) name.gsub( NORM_REGEX, '' ) end def self.normalize( name ) # note: do NOT call sanitize here (keep normalize "atomic" for reuse) ## remove all dots (.), dash (-), º, /, etc. name = strip_norm( name ) name = name.gsub( ' ', '' ) # note: also remove all spaces!!! ## todo/fix: use our own downcase - why? why not? name = downcase_i18n( name ) ## do NOT care about upper and lowercase for now name end end # class League end # module Import end # module SportDb
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sportdb-formats-0.4.0 | lib/sportdb/formats/structs/league.rb |