Class: Sports::Team
- Inherits:
-
Object
- Object
- Sports::Team
- Defined in:
- lib/sportdb/structs/team.rb
Overview
shared base for clubs AND natinal_teams
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alt_names ⇒ Object
todo: use just names for alt_names - why? why not?.
-
#code ⇒ Object
todo: use just names for alt_names - why? why not?.
-
#country ⇒ Object
todo: use just names for alt_names - why? why not?.
-
#key ⇒ Object
all names.
-
#name ⇒ Object
todo: use just names for alt_names - why? why not?.
-
#wikipedia ⇒ Object
special import only attribs.
-
#year ⇒ Object
todo: use just names for alt_names - why? why not?.
-
#year_end ⇒ Object
todo: use just names for alt_names - why? why not?.
Instance Method Summary collapse
- #historic? ⇒ Boolean (also: #past?)
-
#initialize(**kwargs) ⇒ Team
constructor
A new instance of Team.
- #names ⇒ Object
- #update(**kwargs) ⇒ Object
- #wikipedia? ⇒ Boolean
- #wikipedia_url ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ Team
Returns a new instance of Team.
65 66 67 68 69 |
# File 'lib/sportdb/structs/team.rb', line 65 def initialize( **kwargs ) @alt_names = [] update( **kwargs ) unless kwargs.empty? end |
Instance Attribute Details
#alt_names ⇒ Object
todo: use just names for alt_names - why? why not?
7 8 9 |
# File 'lib/sportdb/structs/team.rb', line 7 def alt_names @alt_names end |
#code ⇒ Object
todo: use just names for alt_names - why? why not?
7 8 9 |
# File 'lib/sportdb/structs/team.rb', line 7 def code @code end |
#country ⇒ Object
todo: use just names for alt_names - why? why not?
7 8 9 |
# File 'lib/sportdb/structs/team.rb', line 7 def country @country end |
#key ⇒ Object
all names
7 8 9 |
# File 'lib/sportdb/structs/team.rb', line 7 def key @key end |
#name ⇒ Object
todo: use just names for alt_names - why? why not?
7 8 9 |
# File 'lib/sportdb/structs/team.rb', line 7 def name @name end |
#wikipedia ⇒ Object
special import only attribs
44 45 46 |
# File 'lib/sportdb/structs/team.rb', line 44 def wikipedia @wikipedia end |
#year ⇒ Object
todo: use just names for alt_names - why? why not?
7 8 9 |
# File 'lib/sportdb/structs/team.rb', line 7 def year @year end |
#year_end ⇒ Object
todo: use just names for alt_names - why? why not?
7 8 9 |
# File 'lib/sportdb/structs/team.rb', line 7 def year_end @year_end end |
Instance Method Details
#historic? ⇒ Boolean Also known as: past?
47 |
# File 'lib/sportdb/structs/team.rb', line 47 def historic?() @year_end ? true : false; end |
#names ⇒ Object
13 14 15 16 |
# File 'lib/sportdb/structs/team.rb', line 13 def names ## todo/check: add alt_names_auto too? - why? why not? [@name] + @alt_names end |
#update(**kwargs) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/sportdb/structs/team.rb', line 71 def update( **kwargs ) @key = kwargs[:key] if kwargs.has_key?( :key ) @name = kwargs[:name] if kwargs.has_key?( :name ) @code = kwargs[:code] if kwargs.has_key?( :code ) @alt_names = kwargs[:alt_names] if kwargs.has_key?( :alt_names ) self ## note - MUST return self for chaining end |
#wikipedia? ⇒ Boolean
51 |
# File 'lib/sportdb/structs/team.rb', line 51 def wikipedia?() @wikipedia; end |
#wikipedia_url ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sportdb/structs/team.rb', line 52 def wikipedia_url if @wikipedia ## note: replace spaces with underscore (-) ## e.g. Club Brugge KV => Club_Brugge_KV ## todo/check/fix: ## check if "plain" dash (-) needs to get replaced with typographic dash?? "https://en.wikipedia.org/wiki/#{@wikipedia.gsub(' ','_')}" else nil end end |