Class: AMON::Reading
- Inherits:
-
DocumentPart
- Object
- DocumentPart
- AMON::Reading
- Defined in:
- lib/amon/reading.rb
Overview
AMON readings are ‘categories’ of measurements which are taken by devices. For example, one reading may be ‘electricalInput’ with the unit ‘kWh’.
Instance Attribute Summary
Attributes inherited from DocumentPart
Attributes included from JSONHelper
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
One reading is equal to another if the devices are equal and they are the same type.
-
#accuracy ⇒ Numeric
The accuracy of the reading.
-
#durational? ⇒ Boolean
The opposite of #instantaneous?.
-
#frequency ⇒ Numeric
The frequency of the reading.
- #id ⇒ String
- #instantaneous? ⇒ true, false
-
#max ⇒ Numeric
The expected maximum of the readings.
-
#measurements(entity_id, start_date, end_date, raw = false) ⇒ Array<Measurement>
Measurements for this reading.
-
#min ⇒ Numeric
The expected minimum of the readings.
-
#name ⇒ String
An arbitrary name for the reading.
-
#period ⇒ "instant", "duration"
values taken at a specific point in time (‘instant’), or taken as an average over a period of time (‘duration’).
-
#resolution ⇒ Numeric
The resolution of the reading.
- #type ⇒ String
-
#unit ⇒ String
measurements in.
Methods inherited from DocumentPart
Constructor Details
This class inherits a constructor from AMON::DocumentPart
Instance Method Details
#==(other) ⇒ Boolean
One reading is equal to another if the devices are equal and they are the same type
63 64 65 |
# File 'lib/amon/reading.rb', line 63 def ==(other) device == other.device && type == other.type end |
#accuracy ⇒ Numeric
Returns The accuracy of the reading.
23 |
# File 'lib/amon/reading.rb', line 23 field :accuracy |
#durational? ⇒ Boolean
Returns The opposite of #instantaneous?.
55 56 57 |
# File 'lib/amon/reading.rb', line 55 def durational? !instantaneous? end |
#frequency ⇒ Numeric
Returns The frequency of the reading.
26 |
# File 'lib/amon/reading.rb', line 26 field :frequency |
#id ⇒ String
72 73 74 |
# File 'lib/amon/reading.rb', line 72 def id "#{device.id}-#{type}" end |
#instantaneous? ⇒ true, false
50 51 52 |
# File 'lib/amon/reading.rb', line 50 def instantaneous? period == "instant" end |
#max ⇒ Numeric
Returns The expected maximum of the readings.
32 |
# File 'lib/amon/reading.rb', line 32 field :max |
#measurements(entity_id, start_date, end_date, raw = false) ⇒ Array<Measurement>
Returns Measurements for this reading.
44 45 46 |
# File 'lib/amon/reading.rb', line 44 def measurements(entity_id, start_date, end_date, raw = false) device.measurements_by_name(entity_id, start_date, end_date, raw)[type] || [] end |
#min ⇒ Numeric
Returns The expected minimum of the readings.
29 |
# File 'lib/amon/reading.rb', line 29 field :min |
#name ⇒ String
Returns An arbitrary name for the reading.
13 |
# File 'lib/amon/reading.rb', line 13 field :name |
#period ⇒ "instant", "duration"
values taken at a specific point in time (‘instant’), or taken as an average over a period of time (‘duration’)
37 |
# File 'lib/amon/reading.rb', line 37 field :period, :default => "instant" |
#resolution ⇒ Numeric
Returns The resolution of the reading.
20 |
# File 'lib/amon/reading.rb', line 20 field :resolution |