Sha256: 3257c4963620cfc668d78531c494a355a3b4022062c914b41d75f537751a3473

Contents?: true

Size: 404 Bytes

Versions: 1

Compression:

Stored size: 404 Bytes

Contents

# frozen_string_literal: true
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

  include WannabeBool::Aliasing
end

class String
  include WannabeBool::String
end

Version data entries

1 entries across 1 versions & 1 rubygems

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