Sha256: e497fee5b8dcd50540bf2695aec8406f56816c4763d5f1a4ef3a8cd618ae2082

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

module EspnFflApi
  class Team
    attr_reader :id, :team_name, :owners_uuids, :abbrev, :logo_url, :points_for, :points_against, :wins, :losses, :ties

    def initialize(id:, team_name:, owners_uuids:, abbrev:, logo_url:, points_for:, points_against:, wins:, losses:, ties:)
      @id = id
      @team_name = team_name
      @owners_uuids = owners_uuids
      @abbrev = abbrev
      @logo_url = logo_url
      @points_for = points_for
      @points_against = points_against
      @wins = wins
      @losses = losses
      @ties = ties
    end

    def self.build(team_hash)
      new(
        id: team_hash["id"],
        team_name: "#{team_hash["location"]} #{team_hash["nickname"]}",
        owners_uuids: team_hash["owners"],
        abbrev: team_hash["abbrev"],
        logo_url: team_hash["logo"],
        points_for: team_hash["record"]["overall"]["pointsFor"],
        points_against: team_hash["record"]["overall"]["pointsAgainst"],
        wins: team_hash["record"]["overall"]["wins"],
        losses: team_hash["record"]["overall"]["losses"],
        ties: team_hash["record"]["overall"]["ties"],
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
espn_ffl_api-0.1.4 lib/espn_ffl_api/team.rb
espn_ffl_api-0.1.3 lib/espn_ffl_api/team.rb
espn_ffl_api-0.1.2 lib/espn_ffl_api/team.rb