Module: Spellr::StringFormat
- Included in:
- BaseReporter, InteractiveAdd, InteractiveReplacement
- Defined in:
- lib/spellr/string_format.rb
Class Method Summary collapse
- .aqua(text) ⇒ Object
- .bold(text) ⇒ Object
-
.color_enabled? ⇒ Boolean
TODO: make it work without color.
- .green(text) ⇒ Object
- .normal(text = '') ⇒ Object
- .pluralize(word, count) ⇒ Object
- .red(text) ⇒ Object
Class Method Details
.aqua(text) ⇒ Object
18 19 20 21 22 |
# File 'lib/spellr/string_format.rb', line 18 def aqua(text) return text unless Spellr::StringFormat.color_enabled? "\e[36m#{text}#{normal}" end |
.bold(text) ⇒ Object
30 31 32 33 34 |
# File 'lib/spellr/string_format.rb', line 30 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
14 15 16 |
# File 'lib/spellr/string_format.rb', line 14 def color_enabled? true end |
.green(text) ⇒ Object
42 43 44 45 46 |
# File 'lib/spellr/string_format.rb', line 42 def green(text) return text unless Spellr::StringFormat.color_enabled? "\e[1;32m#{text}#{normal}" end |
.normal(text = '') ⇒ Object
24 25 26 27 28 |
# File 'lib/spellr/string_format.rb', line 24 def normal(text = '') return text unless Spellr::StringFormat.color_enabled? "\e[0m#{text}" end |
.pluralize(word, count) ⇒ Object
9 10 11 |
# File 'lib/spellr/string_format.rb', line 9 def pluralize(word, count) "#{count} #{word}#{'s' if count != 1}" end |
.red(text) ⇒ Object
36 37 38 39 40 |
# File 'lib/spellr/string_format.rb', line 36 def red(text) return text unless Spellr::StringFormat.color_enabled? "\e[1;31m#{text}#{normal}" end |