Sha256: e1f7a76c77eb822de65335a38aab235a9cf65d6fafdc22885a2af18b055185ee

Contents?: true

Size: 765 Bytes

Versions: 13

Compression:

Stored size: 765 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

13 entries across 13 versions & 1 rubygems

Version Path
web_translate_it-2.8.3 lib/web_translate_it/util/string_util.rb
web_translate_it-2.8.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.8.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.8.0 lib/web_translate_it/util/string_util.rb
web_translate_it-2.8.0.pre.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.7.6 lib/web_translate_it/util/string_util.rb
web_translate_it-2.7.5 lib/web_translate_it/util/string_util.rb
web_translate_it-2.7.4 lib/web_translate_it/util/string_util.rb
web_translate_it-2.7.3 lib/web_translate_it/util/string_util.rb
web_translate_it-2.7.2 lib/web_translate_it/util/string_util.rb
web_translate_it-2.7.1 lib/web_translate_it/util/string_util.rb
web_translate_it-2.7.0 lib/web_translate_it/util/string_util.rb
web_translate_it-2.6.4 lib/web_translate_it/util/string_util.rb