Sha256: 2d3f4c03b0adf8da754d57b049e4a6b71f13ccaa3a33029ca003ee256891831c

Contents?: true

Size: 392 Bytes

Versions: 1

Compression:

Stored size: 392 Bytes

Contents

# frozen_string_literal: true

TrueClass.class_eval do
  # :nodoc:
  def to_bool
    true
  end
end

FalseClass.class_eval do
  # :nodoc:
  def to_bool
    false
  end
end

NilClass.class_eval do
  # :nodoc:
  def to_bool
    false
  end
end

String.class_eval do
  # :nodoc:
  def to_bool
    match?(/^(true|1|t|y|yes)$/i)
  end
end

Numeric.class_eval do
  delegate :to_bool, to: :to_s
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
to_bool_extension-1.0.0 lib/to_bool_extension.rb