Module: Spellr::StringFormat
- Included in:
- Interactive, Reporter
- Defined in:
- lib/spellr/string_format.rb
Class Method Summary collapse
- .aqua(text) ⇒ Object
- .bold(text) ⇒ Object
- .color_enabled? ⇒ Boolean
- .normal(text = '') ⇒ Object
- .pluralize(word, count) ⇒ Object
- .red(text) ⇒ Object
Class Method Details
.aqua(text) ⇒ Object
19 20 21 22 23 |
# File 'lib/spellr/string_format.rb', line 19 def aqua(text) return text unless Spellr::StringFormat.color_enabled? "\e[36m#{text}#{normal}" end |
.bold(text) ⇒ Object
31 32 33 34 35 |
# File 'lib/spellr/string_format.rb', line 31 def bold(text) return text unless Spellr::StringFormat.color_enabled? "\e[1;39m#{text}#{normal}" end |
.color_enabled? ⇒ Boolean
13 14 15 16 17 |
# File 'lib/spellr/string_format.rb', line 13 def color_enabled? return $stdout.tty? if Spellr.config.color.nil? Spellr.config.color end |
.normal(text = '') ⇒ Object
25 26 27 28 29 |
# File 'lib/spellr/string_format.rb', line 25 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
37 38 39 40 41 |
# File 'lib/spellr/string_format.rb', line 37 def red(text) return text unless Spellr::StringFormat.color_enabled? "\e[1;31m#{text}#{normal}" end |