Class: String

Inherits:
Object show all
Defined in:
lib/helpers/core_ext/to_b.rb

Constant Summary collapse

TRUE_REGEXP =
/^(yes|true|on|t|1|\-1)$/i.freeze
FALSE_REGEXP =
/^(no|false|off|f|0)$/i.freeze

Instance Method Summary collapse

Instance Method Details

#to_bObject



16
17
18
19
20
21
22
23
# File 'lib/helpers/core_ext/to_b.rb', line 16

def to_b
  case self
  when TRUE_REGEXP then true
  when FALSE_REGEXP then false
  else
    to_i != 0
  end
end