Class: MLB::Team

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/mlb/team.rb

Overview

Represents a team

Constant Summary collapse

ALL_STAR_YES =
"Y".freeze
ALL_STAR_NO =
"N".freeze
AZ =

Team ID constants

109
ATH =
133
ATL =
144
BAL =
110
BOS =
111
CHC =
112
CWS =
145
CIN =
113
CLE =
114
COL =
115
DET =
116
HOU =
117
KC =
118
LAA =
108
LAD =
119
MIA =
146
MIL =
158
MIN =
142
NYM =
121
NYY =
147
PHI =
143
PIT =
134
SD =
135
SF =
137
SEA =
136
STL =
138
TB =
139
TEX =
140
TOR =
141
WSH =
120

Instance Method Summary collapse

Instance Method Details

#all_star?Boolean

Returns whether this is an All-Star team

Examples:

team.all_star? #=> false

Returns:

  • (Boolean)

    whether this is an All-Star team



85
# File 'lib/mlb/team.rb', line 85

def all_star? = all_star_status.eql?(ALL_STAR_YES)

#roster(season: nil) ⇒ Array<RosterEntry>

Retrieves the team’s roster

Examples:

team.roster

Parameters:

  • season (Integer, nil) (defaults to: nil)

    the season year (defaults to current year)

Returns:



118
119
120
121
122
# File 'lib/mlb/team.rb', line 118

def roster(season: nil)
  season ||= Utils.current_season
  response = CLIENT.get("teams/#{id}/roster?#{Utils.build_query(season:)}")
  Roster.from_json(response).roster
end