Class: Peanuts::Converter::Convert_decimal

Inherits:
Convert_string show all
Defined in:
lib/peanuts/converters.rb

Overview

A decimal.

Specifier

:decimal

Ruby type

BigDecimal

Options

Accepts all options of Convert_string.

Instance Method Summary collapse

Methods inherited from Peanuts::Converter

create, create!, lookup, lookup!

Constructor Details

#initialize(options) ⇒ Convert_decimal

Returns a new instance of Convert_decimal.



151
152
153
# File 'lib/peanuts/converters.rb', line 151

def initialize(options)
  super
end

Instance Method Details

#from_xml(string) ⇒ Object



159
160
161
# File 'lib/peanuts/converters.rb', line 159

def from_xml(string)
  (string = super(string)) && BigDecimal.new(string)
end

#to_xml(int) ⇒ Object



155
156
157
# File 'lib/peanuts/converters.rb', line 155

def to_xml(int)
  super(int && int.to_s('F'))
end