Class: Cue::Indicator

Inherits:
Object
  • Object
show all
Includes:
ColorFool
Defined in:
lib/cue/indicator.rb

Constant Summary

Constants included from ColorFool

ColorFool::CODES, ColorFool::COLORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ColorFool

#code, #colorize

Constructor Details

#initialize(state) ⇒ Indicator

Returns a new instance of Indicator.



9
10
11
# File 'lib/cue/indicator.rb', line 9

def initialize(state)
  @state = state
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



7
8
9
# File 'lib/cue/indicator.rb', line 7

def state
  @state
end

Instance Method Details

#colorObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/cue/indicator.rb', line 13

def color
  case state
  when :complete
    :green
  when :incomplete
    :red
  else
    :none
  end
end

#symbolObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/cue/indicator.rb', line 24

def symbol
  case state
  when :complete
    '✓'
  when :incomplete
    '✗'
  else
    '?'
  end
end

#to_sObject



35
36
37
# File 'lib/cue/indicator.rb', line 35

def to_s
  colorize(color) { symbol }
end