Sha256: d101e95af47f5aab468ffa8471ad5d34d4dbbce2ea4f3b5ceca4b11db0d77c0d

Contents?: true

Size: 763 Bytes

Versions: 5

Compression:

Stored size: 763 Bytes

Contents

class StringUtil
  def self.backward_truncate(str)
    return '...' << str[str.length - 50 + 3..str.length] if str.length > 50

    spaces = ''
    (50 - str.length).times { spaces << ' ' }
    str.dup << spaces
  end

  def self.success(str)
    WebTranslateIt::Util.can_display_colors? ? "\e[32m#{str}\e[0m" : str
  end

  def self.failure(str)
    WebTranslateIt::Util.can_display_colors? ? "\e[31m#{str}\e[0m" : str
  end

  def self.checksumify(str)
    WebTranslateIt::Util.can_display_colors? ? "\e[33m#{str[0..6]}\e[0m" : str[0..6]
  end

  def self.titleize(str)
    WebTranslateIt::Util.can_display_colors? ? "\e[1m#{str}\e[0m\n\n" : str
  end

  def self.important(str)
    WebTranslateIt::Util.can_display_colors? ? "\e[1m#{str}\e[0m" : str
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
web_translate_it-2.6.3 lib/web_translate_it/util/string_util.rb
web_translate_it-2.6.3.pre1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.6.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.6.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.6.0 lib/web_translate_it/util/string_util.rb