Module: TiltHydrometer::BeaconDecorator

Defined in:
lib/tilt_hydrometer/beacon_decorator.rb

Instance Method Summary collapse

Instance Method Details

#celsiusObject



28
29
30
31
32
# File 'lib/tilt_hydrometer/beacon_decorator.rb', line 28

def celsius
  (
    (temp - 32.0) * (5.0 / 9.0)
  ).round(1)
end

#colorObject



5
6
7
# File 'lib/tilt_hydrometer/beacon_decorator.rb', line 5

def color
  TiltHydrometer::DEVICES[uuid]
end

#gravityObject



13
14
15
16
17
# File 'lib/tilt_hydrometer/beacon_decorator.rb', line 13

def gravity
  gravity_string = data[1].to_s

  "#{gravity_string[-4] || 0}.#{gravity_string[-3..-1]}".to_f
end

#logObject



38
39
40
41
42
# File 'lib/tilt_hydrometer/beacon_decorator.rb', line 38

def log
  LOGGER.debug("Beacon: #{inspect}")
  LOGGER.debug("Data: #{data.inspect}")
  LOGGER.debug("UUID: #{uuid.inspect}")
end

#platoObject



19
20
21
22
23
24
25
26
# File 'lib/tilt_hydrometer/beacon_decorator.rb', line 19

def plato
  (
    (-1 * 616.868) +
    (1111.14 * gravity) -
    (630.272 * (gravity**2)) +
    (135.997 * (gravity**3))
  ).round(1)
end

#tempObject



9
10
11
# File 'lib/tilt_hydrometer/beacon_decorator.rb', line 9

def temp
  data[0].to_i
end

#values_out_of_range?Boolean



34
35
36
# File 'lib/tilt_hydrometer/beacon_decorator.rb', line 34

def values_out_of_range?
  temp > 212
end