class Compendium::BooleanParam

Public Class Methods

new(obj, *) click to toggle source
Calls superclass method
# File lib/compendium/param_types.rb, line 64
def initialize(obj, *)
  # If given 0, 1, or a version thereof (ie. "0"), pass it along
  return super obj.to_i if obj.numeric? && (0..1).cover?(obj.to_i)
  super !!obj ? 0 : 1
end

Public Instance Methods

!() click to toggle source

When negating a BooleanParam, use the value instead

# File lib/compendium/param_types.rb, line 79
def !
  !value
end
boolean?() click to toggle source
# File lib/compendium/param_types.rb, line 70
def boolean?
  true
end
value() click to toggle source
# File lib/compendium/param_types.rb, line 74
def value
  [true, false][self]
end