Sha256: 5df26a10308bfc73ea039a71448de2363e331f7851b52eec88a62856b7513dad

Contents?: true

Size: 793 Bytes

Versions: 61

Compression:

Stored size: 793 Bytes

Contents

class StringUtil

  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

  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

61 entries across 61 versions & 1 rubygems

Version Path
web_translate_it-2.5.4 lib/web_translate_it/util/string_util.rb
web_translate_it-2.5.3 lib/web_translate_it/util/string_util.rb
web_translate_it-2.5.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.5.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.5.0 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.12 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.11 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.10 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.9 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.8 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.7 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.6 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.5 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.4 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.3 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.4.0 lib/web_translate_it/util/string_util.rb
web_translate_it-2.3.4 lib/web_translate_it/util/string_util.rb
web_translate_it-2.3.3 lib/web_translate_it/util/string_util.rb