Class: Withings::Api::MeasurementGroup

Inherits:
Object
  • Object
show all
Includes:
ResultsHelpers
Defined in:
lib/withings-api/results/measure_getmeas_results.rb

Overview

Class encapsulating a MeasurementGroup

See www.withings.com/en/api/wbsapiv2

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ResultsHelpers

#coerce_hash

Constructor Details

#initialize(json_string_or_hash) ⇒ MeasurementGroup

Returns a new instance of MeasurementGroup.



34
35
36
37
38
39
40
41
42
43
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 34

def initialize(json_string_or_hash)
  hash = coerce_hash json_string_or_hash

  #"grpid"=>2909, "attrib"=>0, "date"=>1222930968, "category"=>1, "measures
  @id = hash["grpid"]
  @date_raw = hash["date"]
  @attribution = AttributionType.lookup(hash["attrib"])
  @category = CategoryType.lookup(hash["category"])
  @measurements = hash["measures"].map { |h| Measurement.new(h) }
end

Instance Attribute Details

#attributionObject (readonly)

Returns the value of attribute attribution.



32
33
34
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 32

def attribution
  @attribution
end

#categoryObject (readonly)

Returns the value of attribute category.



32
33
34
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 32

def category
  @category
end

#date_rawObject (readonly)

Returns the value of attribute date_raw.



32
33
34
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 32

def date_raw
  @date_raw
end

#idObject (readonly)

Returns the value of attribute id.



32
33
34
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 32

def id
  @id
end

#measurementsObject (readonly)

Returns the value of attribute measurements.



32
33
34
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 32

def measurements
  @measurements
end

Instance Method Details

#dateObject



45
46
47
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 45

def date
  Time.at(date_raw)
end