Class: MLB::Players

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

Class Method Summary collapse

Class Method Details

.all(season: Time.now.year, sport: Sport.new(id: 1)) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/mlb/players.rb', line 16

def self.all(season: Time.now.year, sport: Sport.new(id: 1))
  sport_id = sport.respond_to?(:id) ? sport.id : sport
  params = {season:}
  query_string = URI.encode_www_form(params)
  response = CLIENT.get("sports/#{sport_id}/players?#{query_string}")
  players = from_json(response)
  players.players
end