Class: Hlockey::Team::Stadium

Inherits:
Object
  • Object
show all
Defined in:
lib/hlockey/team/stadium.rb

Overview

A Team’s stadium

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_name:, hlockey_type:, nickname: nil, description: nil, team: nil) ⇒ Stadium

Returns a new instance of Stadium.

Parameters:

  • full_name (String)
  • hlockey_type (String)
  • nickname (String, nil) (defaults to: nil)
  • description (String, nil) (defaults to: nil)
  • team (Team, nil) (defaults to: nil)


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

#descriptionString? (readonly)

Returns:

  • (String, nil)


10
11
12
# File 'lib/hlockey/team/stadium.rb', line 10

def description
  @description
end

#full_nameString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/hlockey/team/stadium.rb', line 7

def full_name
  @full_name
end

#hlockey_typeString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/hlockey/team/stadium.rb', line 7

def hlockey_type
  @hlockey_type
end

#nicknameString? (readonly)

Returns:

  • (String, nil)


10
11
12
# File 'lib/hlockey/team/stadium.rb', line 10

def nickname
  @nickname
end

#teamTeam

Returns:



13
14
15
# File 'lib/hlockey/team/stadium.rb', line 13

def team
  @team
end

Instance Method Details

#to_h(simple: false) ⇒ Hash

Returns:

  • (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_sString

The name (and nickname, if it exists) of the stadium Used for quickly showing which Stadium a Game is taking place at

Returns:

  • (String)


47
48
49
# File 'lib/hlockey/team/stadium.rb', line 47

def to_s
  @nickname.nil? ? @full_name : "#{@full_name} (\"#{@nickname}\")"
end