Class: TiltHydrometer::Beacon
- Inherits:
-
Object
- Object
- TiltHydrometer::Beacon
- Defined in:
- lib/tilt_hydrometer/beacon.rb
Instance Method Summary collapse
- #celsius ⇒ Object
- #color ⇒ Object
- #gravity ⇒ Object
-
#initialize(uuid, temp, gravity) ⇒ Beacon
constructor
A new instance of Beacon.
- #log ⇒ Object
- #plato ⇒ Object
- #pro? ⇒ Boolean
- #temp ⇒ Object
- #uuid ⇒ Object
- #values_out_of_range? ⇒ Boolean
Constructor Details
#initialize(uuid, temp, gravity) ⇒ Beacon
Returns a new instance of Beacon.
5 6 7 8 9 |
# File 'lib/tilt_hydrometer/beacon.rb', line 5 def initialize(uuid, temp, gravity) @uuid = uuid @temp = temp @gravity = gravity end |
Instance Method Details
#celsius ⇒ Object
46 47 48 49 50 |
# File 'lib/tilt_hydrometer/beacon.rb', line 46 def celsius ( (temp - 32.0) * (5.0 / 9.0) ).round(1) end |
#color ⇒ Object
15 16 17 |
# File 'lib/tilt_hydrometer/beacon.rb', line 15 def color TiltHydrometer::DEVICES[@uuid] end |
#gravity ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/tilt_hydrometer/beacon.rb', line 27 def gravity gravity_string = @gravity.to_s if pro? "#{gravity_string[-5] || 0}.#{gravity_string[-4..-1]}".to_f else "#{gravity_string[-4] || 0}.#{gravity_string[-3..-1]}".to_f end end |
#log ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/tilt_hydrometer/beacon.rb', line 56 def log LOGGER.debug("Beacon: #{inspect}") LOGGER.debug("Temp: #{temp}") LOGGER.debug("Celsius: #{celsius}") LOGGER.debug("Gravity: #{gravity}") LOGGER.debug("Color: #{color}") LOGGER.debug("UUID: #{@uuid}") end |
#plato ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/tilt_hydrometer/beacon.rb', line 37 def plato ( (-1 * 616.868) + (1111.14 * gravity) - (630.272 * (gravity**2)) + (135.997 * (gravity**3)) ).round(1) end |
#pro? ⇒ Boolean
65 66 67 |
# File 'lib/tilt_hydrometer/beacon.rb', line 65 def pro? @gravity.to_s[-5] == '1' end |
#temp ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/tilt_hydrometer/beacon.rb', line 19 def temp if pro? @temp.to_i/10.0 else @temp.to_i end end |
#uuid ⇒ Object
11 12 13 |
# File 'lib/tilt_hydrometer/beacon.rb', line 11 def uuid @uuid end |
#values_out_of_range? ⇒ Boolean
52 53 54 |
# File 'lib/tilt_hydrometer/beacon.rb', line 52 def values_out_of_range? temp > 212 || temp < 1 end |