Sha256: 572e55c9ee4d5aafd78d5ea2290fb712b61e1b143289b58fd89cbe9fa67fc0f4

Contents?: true

Size: 706 Bytes

Versions: 7

Compression:

Stored size: 706 Bytes

Contents

#
require 'active_support/core_ext/string/filters'
require 'active_support/inflector/transliterate'

module Brcobranca
  # Métodos auxiliares de formatação de strings
  module FormatacaoString
    # Formata o tamanho da string
    # para o tamanho passado
    # se a string for menor, adiciona espacos a direita
    # se a string for maior, trunca para o num. de caracteres
    #
    def format_size(size)
      if self.size > size
        ActiveSupport::Inflector.transliterate(truncate(size, omission: ''))
      else
        ActiveSupport::Inflector.transliterate(ljust(size, ' '))
      end
    end
  end
end

[String].each do |klass|
  klass.class_eval { include Brcobranca::FormatacaoString }
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
brcobranca-8.0.0 lib/brcobranca/formatacao_string.rb
brcobranca-7.3.0 lib/brcobranca/formatacao_string.rb
brcobranca-7.2.2 lib/brcobranca/formatacao_string.rb
brcobranca-7.2.1 lib/brcobranca/formatacao_string.rb
brcobranca-7.2.0 lib/brcobranca/formatacao_string.rb
brcobranca-7.1.0 lib/brcobranca/formatacao_string.rb
brcobranca-7.0.0 lib/brcobranca/formatacao_string.rb