Class: ParamsReady::Value::IntegerCoder

Inherits:
Coder show all
Defined in:
lib/params_ready/value/coder.rb

Class Method Summary collapse

Methods inherited from Coder

instance

Methods included from Coercion

#strict_default?, #try_coerce

Methods inherited from AbstractCoder

value_class_name

Methods included from Extensions::ClassReaderWriter

#class_reader_writer

Class Method Details

.coerce(input, _) ⇒ Object



101
102
103
104
105
106
# File 'lib/params_ready/value/coder.rb', line 101

def self.coerce(input, _)
  return nil if input.nil? || input == ''

  base = 10 if input.is_a? String
  Integer(input, base)
end

.format(value, format) ⇒ Object



108
109
110
# File 'lib/params_ready/value/coder.rb', line 108

def self.format(value, format)
  value.to_s
end