Class: Biscuit::Monitor::Cinr

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level = 0) ⇒ Cinr

Returns a new instance of Cinr.



10
11
12
# File 'lib/biscuit-monitor/cinr.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/cinr.rb', line 8

def level
  @level
end

Instance Method Details

#foreground_colorObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/biscuit-monitor/cinr.rb', line 18

def foreground_color
  case
    when @level > 24 then
      :green
    when (13..24).include?(@level) then
      :light_green
    when (8..12).include?(@level) then
      :yellow
    when (3..7).include?(@level) then
      :light_red
    when @level < 3 then
      :red
    else
      :white
  end
end

#messageObject



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

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