Class: Infostrada::Player
- Inherits:
-
Object
- Object
- Infostrada::Player
- Defined in:
- lib/infostrada/player.rb
Instance Attribute Summary collapse
-
#birthdate ⇒ Object
Returns the value of attribute birthdate.
-
#contract_ends_at ⇒ Object
Returns the value of attribute contract_ends_at.
-
#contract_starts_at ⇒ Object
Returns the value of attribute contract_starts_at.
-
#function ⇒ Object
Returns the value of attribute function.
-
#function_type ⇒ Object
The function_type variable maps Infostradas n_FunctionType and can have one of these values:.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nation ⇒ Object
Returns the value of attribute nation.
-
#person_id ⇒ Object
Returns the value of attribute person_id.
-
#season_stats ⇒ Object
Returns the value of attribute season_stats.
-
#shirt_number ⇒ Object
Returns the value of attribute shirt_number.
-
#short_name ⇒ Object
Returns the value of attribute short_name.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Player
constructor
A new instance of Player.
- #name? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Player
Returns a new instance of Player.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/infostrada/player.rb', line 18 def initialize(hash) @person_id = hash['n_PersonID'] @name = hash['c_Person'] @short_name = hash['c_PersonShort'] @birthdate = Formatter.format_date(hash['d_BirthDate']) # Function is one string like "Goalkeeper", "Defender", "Midfielder", "Forward", "Coach"... # Infostrada doesn't document the function strings so you should rely on function_type @function = hash['c_Function'] @function_type = hash['n_FunctionType'] @shirt_number = hash['n_ShirtNr'] @contract_starts_at = Formatter.format_date(hash['d_ContractStartDate']) @contract_ends_at = Formatter.format_date(hash['d_ContractEndDate']) # Season statistics set_season_stats(hash) @nation = Nation.new(hash, 'person') self end |
Instance Attribute Details
#birthdate ⇒ Object
Returns the value of attribute birthdate.
3 4 5 |
# File 'lib/infostrada/player.rb', line 3 def birthdate @birthdate end |
#contract_ends_at ⇒ Object
Returns the value of attribute contract_ends_at.
4 5 6 |
# File 'lib/infostrada/player.rb', line 4 def contract_ends_at @contract_ends_at end |
#contract_starts_at ⇒ Object
Returns the value of attribute contract_starts_at.
4 5 6 |
# File 'lib/infostrada/player.rb', line 4 def contract_starts_at @contract_starts_at end |
#function ⇒ Object
Returns the value of attribute function.
3 4 5 |
# File 'lib/infostrada/player.rb', line 3 def function @function end |
#function_type ⇒ Object
The function_type variable maps Infostradas n_FunctionType and can have one of these values:
1 = Keeper 2 = Defender 4 = Midfielder 8 = Forward 16 = Trainer 64 = Referee 128 = Linesman 1073741824 = 4th Official
16 17 18 |
# File 'lib/infostrada/player.rb', line 16 def function_type @function_type end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/infostrada/player.rb', line 3 def name @name end |
#nation ⇒ Object
Returns the value of attribute nation.
4 5 6 |
# File 'lib/infostrada/player.rb', line 4 def nation @nation end |
#person_id ⇒ Object
Returns the value of attribute person_id.
3 4 5 |
# File 'lib/infostrada/player.rb', line 3 def person_id @person_id end |
#season_stats ⇒ Object
Returns the value of attribute season_stats.
4 5 6 |
# File 'lib/infostrada/player.rb', line 4 def season_stats @season_stats end |
#shirt_number ⇒ Object
Returns the value of attribute shirt_number.
3 4 5 |
# File 'lib/infostrada/player.rb', line 3 def shirt_number @shirt_number end |
#short_name ⇒ Object
Returns the value of attribute short_name.
3 4 5 |
# File 'lib/infostrada/player.rb', line 3 def short_name @short_name end |
Instance Method Details
#name? ⇒ Boolean
42 43 44 |
# File 'lib/infostrada/player.rb', line 42 def name? @name && !@name.empty? end |