Class: Caligrafo::Converter::Decimal
- Defined in:
- lib/caligrafo/converter.rb
Instance Attribute Summary
Attributes inherited from Base
#alinhamento, #preenchimento, #tipos
Instance Method Summary collapse
-
#initialize ⇒ Decimal
constructor
A new instance of Decimal.
- #string_to_value(string) ⇒ Object
- #value_to_string(valor) ⇒ Object
Methods inherited from Numerico
Methods inherited from Base
Constructor Details
#initialize ⇒ Decimal
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 |