Class: ONIX2::Formatters
- Inherits:
-
Object
- Object
- ONIX2::Formatters
- Defined in:
- lib/onix2.rb
Constant Summary collapse
- TWO_DIGITS =
->(value, *context) { if value.is_a?(Array) value.each_with_index do |val, index| value[index] = ONIX2::Formatters::two_digits_format(val) end else ONIX2::Formatters::two_digits_format(value) end }
- YYYYMMDD =
->(value, *context) { value.strftime("%Y%m%d") if value.respond_to? :strftime }
- DECIMAL =
->(value, *context) { case value when nil then nil when BigDecimal then value.to_s("F") else value.to_s end }
Class Method Summary collapse
Class Method Details
.two_digits_format(value) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/onix2.rb', line 23 def self.two_digits_format(value) if value.nil? nil elsif value.to_i < 10 "%02i" % value elsif value.to_i > 99 value.to_s[-2,2] else value.to_s end end |