Class: IoT::HumitureSensor

Inherits:
TemperatureSensor show all
Defined in:
lib/iot/humiture_sensor.rb

Overview

HumitureSensor - combined humidity & temperature sensor

Direct Known Subclasses

BMxSensor, DHTxxSensor, HTU21D

Instance Method Summary collapse

Methods inherited from TemperatureSensor

#celsius, #fahrenheit, #kelvin, #reaumur, #temperature

Methods inherited from DigitalReceptor

one_wire_file

Methods inherited from Receptor

#model_name, #name, #read

Constructor Details

#initializeHumitureSensor

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

#humidityObject

Humidity in per cents



18
19
20
# File 'lib/iot/humiture_sensor.rb', line 18

def humidity
  @humidity
end

#read_dataObject



13
14
15
# File 'lib/iot/humiture_sensor.rb', line 13

def read_data
  [@humidity, @temperature]
end

#to_sObject

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