Class: DHT11::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/dht11/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_codeObject (readonly)

Returns the value of attribute error_code.



9
10
11
# File 'lib/dht11/result.rb', line 9

def error_code
  @error_code
end

#humidityObject (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

#temperatureObject (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_fObject 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

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/dht11/result.rb', line 17

def valid?
  @error_code == Err::NO_ERROR
end