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.3.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.3.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.3.0 lib/web_translate_it/util/string_util.rb
web_translate_it-2.2.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.2.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.2.0 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.8 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.7 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.6 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.5 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.4 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.3 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.1.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.8 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.7 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.6 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.5 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.4 lib/web_translate_it/util/string_util.rb
web_translate_it-2.0.3 lib/web_translate_it/util/string_util.rb