Class: EspnPub::Entities::Game

Inherits:
Base
  • Object
show all
Defined in:
lib/espn_pub/entities/game.rb

Overview

Represents a game between two teams.

Defined Under Namespace

Modules: Type

Constant Summary collapse

GAME_TYPES =
{
  1 => Type::PRESEASON,
  2 => Type::REGULAR,
  3 => Type::POSTSEASON
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Instance Method Summary collapse

Constructor Details

#initialize(id:, home_team:, away_team:, date:, type: nil) ⇒ Game

Initialize a Game entity.

Parameters:

  • id (String)

    The game identifier.

  • home_team (EspnPub::Entities::Team)

    The home team.

  • away_team (EspnPub::Entities::Team)

    The away team.

  • date (DateTime)

    The scheduled game date.

  • type (String) (defaults to: nil)

    The type of the game.



28
29
30
31
32
33
34
35
# File 'lib/espn_pub/entities/game.rb', line 28

def initialize(id:, home_team:, away_team:, date:, type: nil)
  @id = id
  @home_team = home_team
  @away_team = away_team
  @date = date
  @type = type
  super()
end

Instance Attribute Details

#away_teamObject (readonly)

Returns the value of attribute away_team.



19
20
21
# File 'lib/espn_pub/entities/game.rb', line 19

def away_team
  @away_team
end

#dateObject (readonly)

Returns the value of attribute date.



19
20
21
# File 'lib/espn_pub/entities/game.rb', line 19

def date
  @date
end

#home_teamObject (readonly)

Returns the value of attribute home_team.



19
20
21
# File 'lib/espn_pub/entities/game.rb', line 19

def home_team
  @home_team
end

#idObject (readonly)

Returns the value of attribute id.



19
20
21
# File 'lib/espn_pub/entities/game.rb', line 19

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



19
20
21
# File 'lib/espn_pub/entities/game.rb', line 19

def type
  @type
end