Module: BooleanEvaluator
- Defined in:
- lib/housing_misc/boolean_evaluator.rb
Class Method Summary collapse
Class Method Details
.eval(val) ⇒ Object
2 3 4 5 6 |
# File 'lib/housing_misc/boolean_evaluator.rb', line 2 def self.eval(val) return true if val == true || val.to_s =~ (/^(true|t|yes|y|1|on)$/i) return false if val == false || val.nil? || val.to_s =~ (/^(false|f|no|n|0|off)$/i) raise ArgumentError.new("invalid value for Boolean: \"#{val}\"") end |