Class: Melitta::Coercers::Boolean

Inherits:
Struct
  • Object
show all
Defined in:
lib/melitta/coercers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject

Returns the value of attribute input

Returns:

  • (Object)

    the current value of input



58
59
60
# File 'lib/melitta/coercers.rb', line 58

def input
  @input
end

Instance Method Details

#outputObject



64
65
66
# File 'lib/melitta/coercers.rb', line 64

def output
  (input =~ (/(true|1)$/i)) === 0
end

#valid?Boolean

Returns:



60
61
62
# File 'lib/melitta/coercers.rb', line 60

def valid?
  input.blank? || input =~ (/\A(true|1|false|0)\z/i)
end