Module: Spellr::StringFormat

Included in:
BaseReporter, InteractiveAdd, InteractiveReplacement
Defined in:
lib/spellr/string_format.rb

Class Method Summary collapse

Class Method Details

.aqua(text) ⇒ Object



16
17
18
19
20
# File 'lib/spellr/string_format.rb', line 16

def aqua(text)
  return text unless Spellr::StringFormat.color_enabled?

  "\e[36m#{text}#{normal}"
end

.bold(text) ⇒ Object



28
29
30
31
32
# File 'lib/spellr/string_format.rb', line 28

def bold(text)
  return text unless Spellr::StringFormat.color_enabled?

  "\e[1;39m#{text}#{normal}"
end

.color_enabled?Boolean

TODO: make it work without color



12
13
14
# File 'lib/spellr/string_format.rb', line 12

def color_enabled?
  true
end

.green(text) ⇒ Object



40
41
42
43
44
# File 'lib/spellr/string_format.rb', line 40

def green(text)
  return text unless Spellr::StringFormat.color_enabled?

  "\e[1;32m#{text}#{normal}"
end

.normal(text = '') ⇒ Object



22
23
24
25
26
# File 'lib/spellr/string_format.rb', line 22

def normal(text = '')
  return text unless Spellr::StringFormat.color_enabled?

  "\e[0m#{text}"
end

.pluralize(word, count) ⇒ Object



7
8
9
# File 'lib/spellr/string_format.rb', line 7

def pluralize(word, count)
  "#{count} #{word}#{'s' if count != 1}"
end

.red(text) ⇒ Object



34
35
36
37
38
# File 'lib/spellr/string_format.rb', line 34

def red(text)
  return text unless Spellr::StringFormat.color_enabled?

  "\e[1;31m#{text}#{normal}"
end