Sha256: d1ace265e91f79466021d659e8c0483cc26fc0032e9eb7db3e962b99eed13426

Contents?: true

Size: 341 Bytes

Versions: 1

Compression:

Stored size: 341 Bytes

Contents

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

  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
end

class String
  include WannabeBool::String
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wannabe_bool-0.6.0 lib/wannabe_bool/string.rb