Class: DHT11::Result
- Inherits:
-
Object
- Object
- DHT11::Result
- Defined in:
- lib/dht11/result.rb
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#humidity ⇒ Object
(also: #hum)
readonly
Returns the value of attribute humidity.
-
#temperature ⇒ Object
(also: #temp)
readonly
Returns the value of attribute temperature.
Instance Method Summary collapse
-
#initialize(error_code, temperature, humidity) ⇒ Result
constructor
A new instance of Result.
- #temperature_f ⇒ Object (also: #temp_f)
- #valid? ⇒ Boolean
Constructor Details
#initialize(error_code, temperature, humidity) ⇒ Result
Returns a new instance of Result.
11 12 13 14 15 |
# File 'lib/dht11/result.rb', line 11 def initialize(error_code, temperature, humidity) @error_code = error_code @temperature = temperature @humidity = humidity end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
9 10 11 |
# File 'lib/dht11/result.rb', line 9 def error_code @error_code end |
#humidity ⇒ Object (readonly) Also known as: hum
Returns the value of attribute humidity.
9 10 11 |
# File 'lib/dht11/result.rb', line 9 def humidity @humidity end |
#temperature ⇒ Object (readonly) Also known as: temp
Returns the value of attribute temperature.
9 10 11 |
# File 'lib/dht11/result.rb', line 9 def temperature @temperature end |
Instance Method Details
#temperature_f ⇒ Object Also known as: temp_f
21 22 23 24 |
# File 'lib/dht11/result.rb', line 21 def temperature_f return Float::NAN if @temperature.nan? (@temperature * 9/5) + 32 end |