Class: Withings::Api::Measurement

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

Overview

Class encapsulating a Measurement

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_or_hash) ⇒ Measurement

Returns a new instance of Measurement.



12
13
14
15
16
17
18
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 12

def initialize(json_or_hash)
  hash = coerce_hash json_or_hash

  self.measurement_type = MeasurementType.lookup(hash["type"])
  self.value_raw = hash["value"]
  self.unit = hash["unit"]
end

Instance Attribute Details

#measurement_typeObject

Returns the value of attribute measurement_type.



10
11
12
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 10

def measurement_type
  @measurement_type
end

#unitObject

Returns the value of attribute unit.



10
11
12
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 10

def unit
  @unit
end

#value_rawObject

Returns the value of attribute value_raw.



10
11
12
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 10

def value_raw
  @value_raw
end

Instance Method Details

#valueObject



20
21
22
# File 'lib/withings-api/results/measure_getmeas_results.rb', line 20

def value
  value_raw * 10**unit
end