Sha256: 25e7d37542ddd9bcac160d05c86987304ad5433da6f252397744fb93a24c4097
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
module Strava class StreamSet # Class to contain Strava Streams # http://strava.github.io/api/v3/streams/ attr_reader :type, :data def initialize(data = {}) @streams = {} update(data) end 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 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 def empty? @streams.empty? end def update(data, **opts) @response = data data.each do |stream_data| stream = Stream.new(stream_data) @streams[stream.type] = stream end self end def time; @streams['time']; end def latlng; @streams['latlng']; end def distance; @streams['distance']; end def altitude; @streams['altitude']; end def velocity_smooth; @streams['velocity_smooth']; end def heartrate; @streams['heartrate']; end def cadence; @streams['cadence']; end def watts; @streams['watts']; end def temp; @streams['temp']; end def moving; @streams['moving']; end def grade_smooth; @streams['grade_smooth']; end end end __END__ ca = Strava::Athlete.current_athlete;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strava-0.1.0 | lib/strava/stream_set.rb |