Module: HaveAPI::Client::Parameters::Typed::Boolean

Defined in:
lib/haveapi/client/parameters/typed.rb

Class Method Summary collapse

Class Method Details

.to_b(str) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/haveapi/client/parameters/typed.rb', line 6

def self.to_b(str)
  return true if str === true
  return false if str === false

  if str.respond_to?(:=~)
    return true if str =~ /^(true|t|yes|y|1)$/i
    return false if str =~ /^(false|f|no|n|0)$/i
  end

  false
end