Class: IoT::HumitureSensor
- Inherits:
-
TemperatureSensor
- Object
- Receptor
- DigitalReceptor
- DigitalSensor
- TemperatureSensor
- IoT::HumitureSensor
- Defined in:
- lib/iot/humiture_sensor.rb
Overview
HumitureSensor - combined humidity & temperature sensor
Direct Known Subclasses
Instance Method Summary collapse
-
#humidity ⇒ Object
Humidity in per cents.
-
#initialize ⇒ HumitureSensor
constructor
A new instance of HumitureSensor.
- #read_data ⇒ Object
-
#to_s ⇒ Object
Temperature & humidity as a string.
Methods inherited from TemperatureSensor
#celsius, #fahrenheit, #kelvin, #reaumur, #temperature
Methods inherited from DigitalReceptor
Methods inherited from Receptor
Constructor Details
#initialize ⇒ HumitureSensor
Returns a new instance of HumitureSensor.
9 10 11 |
# File 'lib/iot/humiture_sensor.rb', line 9 def initialize @humidity, @temperature = read_data end |
Instance Method Details
#humidity ⇒ Object
Humidity in per cents
18 19 20 |
# File 'lib/iot/humiture_sensor.rb', line 18 def humidity @humidity end |
#read_data ⇒ Object
13 14 15 |
# File 'lib/iot/humiture_sensor.rb', line 13 def read_data [@humidity, @temperature] end |
#to_s ⇒ Object
Temperature & humidity as a string
23 24 25 |
# File 'lib/iot/humiture_sensor.rb', line 23 def to_s sprintf "%5.2f°, %5.2f %%", @temperature, @humidity end |