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