Class: Biscuit::Monitor::Rssi

Inherits:
Object
  • Object
show all
Defined in:
lib/biscuit-monitor/rssi.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level = 0) ⇒ Rssi

Returns a new instance of Rssi.



10
11
12
# File 'lib/biscuit-monitor/rssi.rb', line 10

def initialize(level=0)
  @level = Integer(level || 0)
end

Instance Attribute Details

#levelObject

Returns the value of attribute level.



8
9
10
# File 'lib/biscuit-monitor/rssi.rb', line 8

def level
  @level
end

Instance Method Details

#foreground_colorObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/biscuit-monitor/rssi.rb', line 18

def foreground_color
  case
    when @level > -50 then
      :green
    when @level < -100 then
      :red
    else
      :yellow
  end
end

#messageObject



14
15
16
# File 'lib/biscuit-monitor/rssi.rb', line 14

def message
  "RSSI: #{@level}dBs".colorize(foreground_color)
end