Sha256: f33daf1605ba49ef36b9fa9b8d10b7e9f171a292a02a333c2414406525893e61

Contents?: true

Size: 801 Bytes

Versions: 5

Compression:

Stored size: 801 Bytes

Contents

# frozen_string_literal: true

require "./lib/mlb_rb/team"
require "date"

module MlbRb
  class Game
    attr_reader :game_pk,
      :home_team,
      :away_team,
      :home_score,
      :away_score,
      :game_date

    def initialize(game_hash)
      @game_pk = game_hash["gamePk"]
      @home_team = Team.new(game_hash["teams"]["home"]["team"])
      @away_team = Team.new(game_hash["teams"]["away"]["team"])
      @home_score = game_hash["teams"]["home"]["score"]
      @away_score = game_hash["teams"]["away"]["score"]
      @game_date = Date.parse(game_hash["gameDate"])
    end

    def home_team_name
      home_team.name
    end

    def home_team_id
      home_team.id
    end

    def away_team_name
      away_team.name
    end

    def away_team_id
      away_team.id
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mlb_rb-0.0.8 lib/mlb_rb/game.rb
mlb_rb-0.0.7 lib/mlb_rb/game.rb
mlb_rb-0.0.5 lib/mlb_rb/game.rb
mlb_rb-0.0.4 lib/mlb_rb/game.rb
mlb_rb-0.0.3 lib/mlb_rb/game.rb