Class: Hlockey::Team::Stadium
- Inherits:
-
Object
- Object
- Hlockey::Team::Stadium
- Defined in:
- lib/hlockey/team/stadium.rb
Overview
A Team’s stadium
Instance Attribute Summary collapse
- #description ⇒ String? readonly
- #full_name ⇒ String readonly
- #hlockey_type ⇒ String readonly
- #nickname ⇒ String? readonly
- #team ⇒ Team
Instance Method Summary collapse
-
#initialize(full_name:, hlockey_type:, nickname: nil, description: nil, team: nil) ⇒ Stadium
constructor
A new instance of Stadium.
- #to_h(simple: false) ⇒ Hash
-
#to_s ⇒ String
The name (and nickname, if it exists) of the stadium Used for quickly showing which Stadium a Game is taking place at.
Constructor Details
#initialize(full_name:, hlockey_type:, nickname: nil, description: nil, team: nil) ⇒ Stadium
Returns a new instance of Stadium.
20 21 22 23 24 25 26 27 |
# File 'lib/hlockey/team/stadium.rb', line 20 def initialize(full_name:, hlockey_type:, nickname: nil, description: nil, team: nil) @full_name = full_name @hlockey_type = hlockey_type @nickname = nickname @description = description @team = team end |
Instance Attribute Details
#description ⇒ String? (readonly)
10 11 12 |
# File 'lib/hlockey/team/stadium.rb', line 10 def description @description end |
#full_name ⇒ String (readonly)
7 8 9 |
# File 'lib/hlockey/team/stadium.rb', line 7 def full_name @full_name end |
#hlockey_type ⇒ String (readonly)
7 8 9 |
# File 'lib/hlockey/team/stadium.rb', line 7 def hlockey_type @hlockey_type end |
#nickname ⇒ String? (readonly)
10 11 12 |
# File 'lib/hlockey/team/stadium.rb', line 10 def nickname @nickname end |
Instance Method Details
#to_h(simple: false) ⇒ Hash
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hlockey/team/stadium.rb', line 30 def to_h(simple: false) res = { nickname: @nickname, full_name: @full_name, description: @description, hlockey_type: @hlockey_type } return res.compact if simple res[:team] = @team.to_s res end |
#to_s ⇒ String
The name (and nickname, if it exists) of the stadium Used for quickly showing which Stadium a Game is taking place at
47 48 49 |
# File 'lib/hlockey/team/stadium.rb', line 47 def to_s @nickname.nil? ? @full_name : "#{@full_name} (\"#{@nickname}\")" end |