Module: WannabeBool::String

Includes:
Aliasing
Included in:
String
Defined in:
lib/wannabe_bool/string.rb

Constant Summary collapse

TRUES =
%W{t true on y yes 1}.freeze
FALSES =
%W{f false off n no 0}.freeze

Instance Method Summary collapse

Methods included from Aliasing

included

Instance Method Details

#to_bObject



6
7
8
9
10
11
12
# File 'lib/wannabe_bool/string.rb', line 6

def to_b
  value = self.strip.downcase
  return true  if TRUES.include?(value)
  return false if FALSES.include?(value)

  WannabeBool.invalid_value_behaviour.call
end