Sha256: 339b9c77d2e0876a315e5d3d37151d51b2c315747e0d0056e951b8915d34aa50

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module Strava
  class RunningRace < Base

    def update(data, **opts)
      @response       = data
      @id             = data['id']
      @resource_state = data['resource_state']

      @name                   = data["name"]
      @start_date_local       = data["start_date_local"]
      @distance               = data["distance"]
      @city                   = data["city"]
      @state                  = data["state"]
      @country                = data["country"]
      @measurement_preference = data["measurement_preference"]
      @running_race_type      = data["running_race_type"]
      @url                    = data["url"]
      @resource_state         = data["resource_state"]
      @status                 = data["status"]
      @website_url            = data["website_url"]
      @route_ids              = data["route_ids"]

      self
    end

    def get_details
      return self if detailed?
      res = client.get(path_base).to_h
      update(res)
      res
    end
    def path_base
      "running_races/#{id}"
    end

    def self.list_races(client, year = Time.now.year)
      res = client.get("running_races", year: year).to_a
      res.map { |hash| new(hash, client: client) }
    end

  end
end


__END__

ca = Strava::Athlete.current_athlete;
races = ca.list_races;
rr = races.first;
rr.get_details

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
strava-0.1.0 lib/strava/running_race.rb