Class: Activite::MeasurementGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/activite/measurement_group.rb

Constant Summary collapse

TYPES =

Types of body measurements collected by Withings devices and supported by this gem. See oauth.withings.com/api/doc#api-Measure-get_measure for details.

{
  1  => Activite::Measure::Weight,
  4  => Activite::Measure::Height,
  5  => Activite::Measure::FatFreeMass,
  6  => Activite::Measure::FatRatio,
  8  => Activite::Measure::FatMassWeight,
  11 => Activite::Measure::Pulse
}

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Activite::MeasurementGroup

Create a new instance with a collection of measurements of the appropriate Activite::Measure type.


22
23
24
25
26
27
28
29
# File 'lib/activite/measurement_group.rb', line 22

def initialize(attrs = {})
  super(attrs)
  return if attrs['measures'].nil?
  @measures = attrs['measures'].collect do |measurement|
    klass = TYPES[measurement['type']]
    klass.new(measurement) unless klass.nil?
  end.reject { |obj| obj.nil? }
end