Class: Boolean
Class Method Summary collapse
-
.from_user_input(value) ⇒ Object
Must be a string that is either “true” or “false”.
Class Method Details
.from_user_input(value) ⇒ Object
Must be a string that is either “true” or “false”
23 24 25 26 27 28 29 30 |
# File 'lib/user_input.rb', line 23 def Boolean.from_user_input(value) if (value.kind_of?(TrueClass) || value.kind_of?(FalseClass) || /(true|false|on|off|y|n|enabled|disabled)/ =~ value.to_s) return !!(/(true|on|y|enabled)/ =~ value.to_s) else return nil end end |