class Strava::StreamSet

Attributes

data[R]

Class to contain Strava Streams strava.github.io/api/v3/streams/

type[R]

Class to contain Strava Streams strava.github.io/api/v3/streams/

Public Class Methods

new(data = {}) click to toggle source
# File lib/strava/stream_set.rb, line 7
def initialize(data = {})
  @streams = {}
  update(data)
end

Public Instance Methods

all() click to toggle source
# File lib/strava/stream_set.rb, line 12
def all
  size = @streams.values.first.size
  size.times.map do |i|
    @streams.map do |type, stream|
      [type, stream[i]]
    end.to_h
  end
end
all2() click to toggle source
# File lib/strava/stream_set.rb, line 21
def all2
  size = @streams.values.first.size
  size.times.map do |i|
    @streams.map do |type, stream|
      { type => stream[i] }
    end.inject(:merge)
  end
end
altitude() click to toggle source
# File lib/strava/stream_set.rb, line 48
def altitude;        @streams['altitude'];        end
cadence() click to toggle source
# File lib/strava/stream_set.rb, line 51
def cadence;         @streams['cadence'];         end
distance() click to toggle source
# File lib/strava/stream_set.rb, line 47
def distance;        @streams['distance'];        end
empty?() click to toggle source
# File lib/strava/stream_set.rb, line 30
def empty?
  @streams.empty?
end
grade_smooth() click to toggle source
# File lib/strava/stream_set.rb, line 55
def grade_smooth;    @streams['grade_smooth'];    end
heartrate() click to toggle source
# File lib/strava/stream_set.rb, line 50
def heartrate;       @streams['heartrate'];       end
latlng() click to toggle source
# File lib/strava/stream_set.rb, line 46
def latlng;          @streams['latlng'];          end
moving() click to toggle source
# File lib/strava/stream_set.rb, line 54
def moving;          @streams['moving'];          end
temp() click to toggle source
# File lib/strava/stream_set.rb, line 53
def temp;            @streams['temp'];            end
time() click to toggle source
# File lib/strava/stream_set.rb, line 45
def time;            @streams['time'];            end
update(data, **opts) click to toggle source
# File lib/strava/stream_set.rb, line 34
def update(data, **opts)
  @response = data

  data.each do |stream_data|
    stream = Stream.new(stream_data)
    @streams[stream.type] = stream
  end

  self
end
velocity_smooth() click to toggle source
# File lib/strava/stream_set.rb, line 49
def velocity_smooth; @streams['velocity_smooth']; end
watts() click to toggle source
# File lib/strava/stream_set.rb, line 52
def watts;           @streams['watts'];           end