Class: Caligrafo::Converter::Base
- Inherits:
-
Object
- Object
- Caligrafo::Converter::Base
- Defined in:
- lib/caligrafo/converter.rb
Instance Attribute Summary collapse
-
#alinhamento ⇒ Object
readonly
Returns the value of attribute alinhamento.
-
#preenchimento ⇒ Object
readonly
Returns the value of attribute preenchimento.
-
#tipos ⇒ Object
readonly
Returns the value of attribute tipos.
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #preencher(string, tamanho) ⇒ Object
- #string_to_value(string) ⇒ Object
- #value_to_string(valor) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
31 32 33 34 35 |
# File 'lib/caligrafo/converter.rb', line 31 def initialize @tipos = [] @alinhamento = :esquerda @preenchimento = ' ' end |
Instance Attribute Details
#alinhamento ⇒ Object (readonly)
Returns the value of attribute alinhamento.
29 30 31 |
# File 'lib/caligrafo/converter.rb', line 29 def alinhamento @alinhamento end |
#preenchimento ⇒ Object (readonly)
Returns the value of attribute preenchimento.
29 30 31 |
# File 'lib/caligrafo/converter.rb', line 29 def preenchimento @preenchimento end |
#tipos ⇒ Object (readonly)
Returns the value of attribute tipos.
29 30 31 |
# File 'lib/caligrafo/converter.rb', line 29 def tipos @tipos end |
Instance Method Details
#preencher(string, tamanho) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/caligrafo/converter.rb', line 45 def preencher(string, tamanho) if self.alinhamento == :direita string = string.rjust tamanho, self.preenchimento else string = string.ljust tamanho, self.preenchimento end string = string[0..(tamanho - 1)] if string.size > tamanho string end |
#string_to_value(string) ⇒ Object
41 42 43 |
# File 'lib/caligrafo/converter.rb', line 41 def string_to_value(string) string.strip end |
#value_to_string(valor) ⇒ Object
37 38 39 |
# File 'lib/caligrafo/converter.rb', line 37 def value_to_string(valor) valor.to_s end |