Class: Unit::Types::Boolean

Inherits:
Object
  • Object
show all
Defined in:
lib/unit-ruby/types/boolean.rb

Class Method Summary collapse

Class Method Details

.cast(value) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/unit-ruby/types/boolean.rb', line 4

def self.cast(value)
  return nil if value.nil?

  case value
  when 'false', '0', 0, false
    false
  when 'true', '1', 1, true
    true
  end
end