Class: StringUtil
- Inherits:
-
Object
- Object
- StringUtil
- Defined in:
- lib/web_translate_it/util/string_util.rb
Class Method Summary collapse
- .backward_truncate(str) ⇒ Object
- .checksumify(str) ⇒ Object
- .failure(str) ⇒ Object
- .important(str) ⇒ Object
- .success(str) ⇒ Object
- .titleize(str) ⇒ Object
Class Method Details
.backward_truncate(str) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/web_translate_it/util/string_util.rb', line 3 def self.backward_truncate(str) if str.length <= 50 spaces = "" (50-str.length).times{ spaces << " " } return str.dup << spaces else return "..." << str[str.length-50+3..str.length] end end |
.checksumify(str) ⇒ Object
21 22 23 |
# File 'lib/web_translate_it/util/string_util.rb', line 21 def self.checksumify(str) WebTranslateIt::Util.can_display_colors? ? "\e[33m#{str[0..6]}\e[0m" : str[0..6] end |
.failure(str) ⇒ Object
17 18 19 |
# File 'lib/web_translate_it/util/string_util.rb', line 17 def self.failure(str) WebTranslateIt::Util.can_display_colors? ? "\e[31m#{str}\e[0m" : str end |
.important(str) ⇒ Object
29 30 31 |
# File 'lib/web_translate_it/util/string_util.rb', line 29 def self.important(str) WebTranslateIt::Util.can_display_colors? ? "\e[1m#{str}\e[0m" : str end |
.success(str) ⇒ Object
13 14 15 |
# File 'lib/web_translate_it/util/string_util.rb', line 13 def self.success(str) WebTranslateIt::Util.can_display_colors? ? "\e[32m#{str}\e[0m" : str end |
.titleize(str) ⇒ Object
25 26 27 |
# File 'lib/web_translate_it/util/string_util.rb', line 25 def self.titleize(str) WebTranslateIt::Util.can_display_colors? ? "\e[1m#{str}\e[0m\n\n" : str end |