Class: Magiq::Types::Bool

Inherits:
Type
  • Object
show all
Defined in:
lib/magiq/types.rb

Instance Attribute Summary

Attributes inherited from Type

#raw

Instance Method Summary collapse

Methods inherited from Type

cast, #initialize

Constructor Details

This class inherits a constructor from Magiq::Types::Type

Instance Method Details

#cast!Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/magiq/types.rb', line 53

def cast!
  case v = raw.downcase
  when 't', 'true', '1', 'yes', 'y'
    true
  when 'f', 'false', '0', 'no', 'n'
    false
  else
    bad! "provided value of #{raw.inspect} is not permitted, the " \
    "permitted values are: \"true\", or \"false\""
  end
end