Class: ONIX::Formatters
- Inherits:
-
Object
- Object
- ONIX::Formatters
- Defined in:
- lib/onix.rb
Class Method Summary collapse
Class Method Details
.decimal ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/onix.rb', line 19 def self.decimal lambda do |val| if val.nil? nil elsif val.kind_of?(BigDecimal) val.to_s("F") else val.to_s end end end |
.two_digit ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/onix.rb', line 41 def self.two_digit lambda do |val| if val.nil? nil elsif val.to_i < 10 "0#{val}" elsif val.to_i > 99 val.to_s[-2,2] else val.to_s end end end |
.yyyymmdd ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/onix.rb', line 31 def self.yyyymmdd lambda do |val| if val.nil? || !val.respond_to?(:strftime) nil else val.strftime("%Y%m%d") end end end |