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.0.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.0 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.0.rc4 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.0.rc3 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.0.rc2 lib/web_translate_it/util/string_util.rb
web_translate_it-1.10.2 lib/web_translate_it/util/string_util.rb
web_translate_it-1.10.1 lib/web_translate_it/util/string_util.rb
web_translate_it-1.10.0 lib/web_translate_it/util/string_util.rb
web_translate_it-1.9.6 lib/web_translate_it/util/string_util.rb
web_translate_it-1.9.5 lib/web_translate_it/util/string_util.rb
web_translate_it-1.9.4 lib/web_translate_it/util/string_util.rb
web_translate_it-1.9.3 lib/web_translate_it/util/string_util.rb
web_translate_it-1.9.2 lib/web_translate_it/util/string_util.rb
web_translate_it-1.9.1 lib/web_translate_it/util/string_util.rb
web_translate_it-1.9.0 lib/web_translate_it/util/string_util.rb
web_translate_it-1.8.4 lib/web_translate_it/util/string_util.rb
web_translate_it-1.8.3 lib/web_translate_it/util/string_util.rb
web_translate_it-1.8.2.3 lib/web_translate_it/util/string_util.rb
web_translate_it-1.8.2.2 lib/web_translate_it/util/string_util.rb