Class: Xmlstats::Endpoints::Events

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

Class Method Summary collapse

Methods included from Xmlstats::Endpoint

included

Class Method Details

.fetch(date = Date.today, sport = nil) ⇒ Object



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

def self.fetch(date = Date.today, sport = nil)
  date_str = date.strftime("%Y%m%d") unless date.kind_of? String
  params = { date: date_str, sport: sport }
  response = fetch_json("events", params)

  response["event"].map do |event|
    Xmlstats::Objects::Event.new event.merge(date: date)
  end
end