Class: NRSER::Types::Boolean

Inherits:
Is show all
Defined in:
lib/nrser/types/booleans.rb

Overview

Abstract base class for True and False.

Direct Known Subclasses

FalseType, TrueType

Instance Attribute Summary

Attributes inherited from Is

#value

Instance Method Summary collapse

Methods inherited from Is

#==, #default_symbolic, #explain, #test?

Methods inherited from Type

#===, #builtin_inspect, #check, #check!, #default_name, #default_symbolic, #explain, #from_data, #from_s, #has_from_data?, #has_from_s?, #has_to_data?, #inspect, #intersection, #name, #not, #respond_to?, #symbolic, #test, #test?, #to_data, #to_proc, #to_s, #union, #xor

Constructor Details

#initialize(value, **options) ⇒ Boolean

Instantiate a new ‘Boolean`.



34
35
36
37
38
39
40
41
42
# File 'lib/nrser/types/booleans.rb', line 34

def initialize value, **options
  # Check it's a boolean
  unless true.equal?( value ) || false.equal?( value )
    raise ArgumentError.new \
      "`value` arg must be `true` or `false`, found #{ value.inspect }"
  end
  
  super value, **options
end