Class: Xmlstats::Endpoints::MlbStanding

Inherits:
Object
  • Object
show all
Includes:
Xmlstats::Endpoint
Defined in:
lib/xmlstats/endpoints/mlb_standing.rb

Class Method Summary collapse

Methods included from Xmlstats::Endpoint

included

Class Method Details

.fetch(date = Date.today) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/xmlstats/endpoints/mlb_standing.rb', line 5

def self.fetch(date = Date.today)
  date_str = date.strftime("%Y%m%d") unless date.kind_of? String
  response = fetch_json("mlb/standings/#{date_str}")
  standing = response["standing"]

  standing.map do |team_standing|
    Xmlstats::Objects::Standing.new team_standing.merge(date: date)
  end
end