Class: Ds18b20::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/ds18b20/parser.rb

Constant Summary collapse

ERROR_READINGS =
[85000,127687]
MAXIMUM_RETRIES =
3

Instance Method Summary collapse

Constructor Details

#initialize(file_location) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
# File 'lib/ds18b20/parser.rb', line 8

def initialize(file_location)
  @file_location = file_location
  @retries = 0
end

Instance Method Details

#get_temperature_celsiusObject Also known as: celsius



13
14
15
# File 'lib/ds18b20/parser.rb', line 13

def get_temperature_celsius
  get_temperature_from_file
end

#get_temperature_fahrenheitObject Also known as: fahrenheit



17
18
19
# File 'lib/ds18b20/parser.rb', line 17

def get_temperature_fahrenheit
  (get_temperature_from_file * 9/5.0) + 32
end

#get_temperature_kelvinObject Also known as: kelvin



21
22
23
# File 'lib/ds18b20/parser.rb', line 21

def get_temperature_kelvin
  get_temperature_from_file + 273.15
end