Class: Swagger::Boolean
- Inherits:
-
Object
- Object
- Swagger::Boolean
- Defined in:
- lib/swagger/boolean.rb
Constant Summary collapse
- TRUE_REGEXP =
/(y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON)/- FALSE_REGEXP =
/(n|N|no|No|NO|false|False|FALSE|off|Off|OFF)/
Class Method Summary collapse
Class Method Details
.coerce(obj) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/swagger/boolean.rb', line 6 def self.coerce(obj) val = obj.to_s.downcase return true if val.match(TRUE_REGEXP) return false if val.match(FALSE_REGEXP) fail ArgumentError, "#{obj} cannot be coerced to a boolean" end |