class Withings::MeasurementGroup
Constants
- ATTRIBUTION_DEVICE
- ATTRIBUTION_DEVICE_AMBIGUOUS
- ATTRIBUTION_DEVICE_MANUALLY
- ATTRIBUTION_DEVICE_MANUALLY_DURING_CREATION
- BLOOD_PRESSURE_MONITOR_TYPES
- CATEGORY_MEASURE
- CATEGORY_TARGET
- SCALE_TYPES
- TYPE_DIASTOLIC_BLOOD_PRESSURE
- TYPE_FAT_FREE_MASS_WEIGHT
- TYPE_FAT_MASS_WEIGHT
- TYPE_FAT_RATIO
- TYPE_HEART_PULSE
- TYPE_SIZE
- TYPE_SYSTOLIC_BLOOD_PRESSURE
- TYPE_WEIGHT
Attributes
attribution[R]
category[R]
diastolic_blood_pressure[R]
fat[R]
fat_free[R]
group_id[R]
heart_pulse[R]
ratio[R]
size[R]
systolic_blood_pressure[R]
taken_at[R]
weight[R]
Public Class Methods
new(params)
click to toggle source
# File lib/withings/measurement_group.rb, line 24 def initialize(params) params = params.stringify_keys @group_id = params['grpid'] @attribution = params['attrib'] @taken_at = Time.at(params['date']) @category = params['category'] params['measures'].each do |measure| value = (measure['value'] * 10 ** measure['unit']).to_f case measure['type'] when TYPE_WEIGHT then @weight = value when TYPE_SIZE then @size = value when TYPE_FAT_MASS_WEIGHT then @fat = value when TYPE_FAT_RATIO then @ratio = value when TYPE_FAT_FREE_MASS_WEIGHT then @fat_free = value when TYPE_DIASTOLIC_BLOOD_PRESSURE then @diastolic_blood_pressure = value when TYPE_SYSTOLIC_BLOOD_PRESSURE then @systolic_blood_pressure = value when TYPE_HEART_PULSE then @heart_pulse = value end end end
Public Instance Methods
created_at()
click to toggle source
# File lib/withings/measurement_group.rb, line 45 def created_at $stderr.puts "created_at has been deprecated in favour of taken_at. Please updated your code." end
inspect()
click to toggle source
# File lib/withings/measurement_group.rb, line 61 def inspect self.to_s end
measure?()
click to toggle source
# File lib/withings/measurement_group.rb, line 49 def measure? self.category == CATEGORY_MEASURE end
target?()
click to toggle source
# File lib/withings/measurement_group.rb, line 53 def target? self.category == CATEGORY_TARGET end
to_s()
click to toggle source
# File lib/withings/measurement_group.rb, line 57 def to_s "[ Weight: #{self.weight}, Fat: #{self.fat}, Size: #{self.size}, Ratio: #{self.ratio}, Free: #{self.fat_free}, Blood Pressure: #{self.diastolic_blood_pressure}/#{self.systolic_blood_pressure} @ #{self.heart_pulse}, ID: #{self.group_id} (taken at: #{self.taken_at.strftime("%d.%m.%Y %H:%M:%S")})]" end