Class: Team
- Inherits:
-
Object
- Object
- Team
- Defined in:
- lib/fbtxt-pp/models/teams.rb
Constant Summary collapse
- DUMMY =
build( { 'name' => 'N.N.', 'code' => 'UNK', 'country' => 'UNK', } )
Instance Attribute Summary collapse
-
#alt_names ⇒ Object
readonly
Returns the value of attribute alt_names.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #dummy? ⇒ Boolean (also: #unknown?)
-
#initialize(name:, code:, country:, id: nil) ⇒ Team
constructor
attr_accessor :count ## read/write - let's you update (match) count.
-
#keys ⇒ Object
get lookup keys (id+name+alt_names).
Constructor Details
#initialize(name:, code:, country:, id: nil) ⇒ Team
attr_accessor :count ## read/write - let's you update (match) count
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fbtxt-pp/models/teams.rb', line 44 def initialize( name:, code:, country:, id: nil) @alt_names = [] norm = norm_name( name ) if norm != name puts " NORM TEAM NAME >#{name}< => >#{norm}<" @alt_names << name name = norm end ## check for mods/canonical name mod = TEAM_MODS[ name ] if mod puts " MOD TEAM NAME >#{name}< => >#{mod}<" @alt_names << name name = mod end @name = name @code = code @country = country @id = id ## @count = 0 end |
Instance Attribute Details
#alt_names ⇒ Object (readonly)
Returns the value of attribute alt_names.
38 39 40 |
# File 'lib/fbtxt-pp/models/teams.rb', line 38 def alt_names @alt_names end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
38 39 40 |
# File 'lib/fbtxt-pp/models/teams.rb', line 38 def code @code end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
38 39 40 |
# File 'lib/fbtxt-pp/models/teams.rb', line 38 def country @country end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
38 39 40 |
# File 'lib/fbtxt-pp/models/teams.rb', line 38 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
38 39 40 |
# File 'lib/fbtxt-pp/models/teams.rb', line 38 def name @name end |
Class Method Details
.build(h) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/fbtxt-pp/models/teams.rb', line 29 def self.build( h ) ## pp h new( id: h['id'], name: h['name'], code: h['code'], country: h['country'] ) end |
Instance Method Details
#dummy? ⇒ Boolean Also known as: unknown?
89 |
# File 'lib/fbtxt-pp/models/teams.rb', line 89 def dummy?() @name == 'N.N.'; end |
#keys ⇒ Object
get lookup keys (id+name+alt_names)
78 79 80 81 82 83 84 85 86 |
# File 'lib/fbtxt-pp/models/teams.rb', line 78 def keys keys = [] keys << @id if @id keys << slugify(@name) keys += @alt_names.map {|name| slugify(name)} unless @alt_names.empty? ## note - make sure keys are unique keys.uniq end |