Sha256: c7c414b8248e6b0c828fe2105c7a19507ec768d69c05dcda2cd34bef62173d69
Contents?: true
Size: 1.36 KB
Versions: 5
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true 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) clean_str = remove_accents.strip.gsub(/\s+/, ' ').gsub(/[^A-Za-z0-9[[:space:]]]/, '') if clean_str.size > size clean_str.truncate(size) else clean_str.ljust(size, ' ') end end def truncate(truncate_at) return dup unless length > truncate_at (self[0, truncate_at]).to_s end def remove_accents tr( 'ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž', 'AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz' ) end end end [String].each do |klass| klass.class_eval { include Brcobranca::FormatacaoString } end
Version data entries
5 entries across 5 versions & 2 rubygems