Sha256: 39d3047931e67158140c6870f51600f793b84174803a40a10703204d4cb41063

Contents?: true

Size: 410 Bytes

Versions: 4

Compression:

Stored size: 410 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
  # :nodoc:
  def to_bool
    to_s.to_bool
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
to_bool_extension-1.0.0.pre.rc.1 lib/to_bool_extension.rb
to_bool_extension-0.0.5 lib/to_bool_extension.rb
to_bool_extension-0.0.4 lib/to_bool_extension.rb
to_bool_extension-0.0.3 lib/to_bool_extension.rb