Class: Caligrafo::Converter::Decimal

Inherits:
Numerico show all
Defined in:
lib/caligrafo/converter.rb

Instance Attribute Summary

Attributes inherited from Base

#alinhamento, #preenchimento, #tipos

Instance Method Summary collapse

Methods inherited from Numerico

#alinhamento, #preenchimento

Methods inherited from Base

#preencher

Constructor Details

#initializeDecimal

Returns a new instance of Decimal.



92
93
94
# File 'lib/caligrafo/converter.rb', line 92

def initialize
  @tipos = [Float, BigDecimal]
end

Instance Method Details

#string_to_value(string) ⇒ Object



100
101
102
# File 'lib/caligrafo/converter.rb', line 100

def string_to_value(string)
  string.gsub(/(.*)(\d{2})/, '\1.\2').to_f
end

#value_to_string(valor) ⇒ Object



96
97
98
# File 'lib/caligrafo/converter.rb', line 96

def value_to_string(valor)
  ('%.2f' % valor.to_f).gsub('.','')
end