Class: NRSER::Types::Is
Overview
Type satisfied only by it’s exact #value object (identity comparison via ‘#equal?`).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
The exact value for this type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #default_symbolic ⇒ Object
- #explain ⇒ Object
-
#initialize(value, **options) ⇒ Is
constructor
A new instance of Is.
- #test?(value) ⇒ Boolean
Methods inherited from Type
#===, #builtin_inspect, #check, #check!, #default_name, #from_data, #from_s, #has_from_data?, #has_from_s?, #has_to_data?, #inspect, #intersection, #name, #not, #respond_to?, #symbolic, #test, #to_data, #to_proc, #to_s, #union, #xor
Constructor Details
#initialize(value, **options) ⇒ Is
Returns a new instance of Is.
31 32 33 34 |
# File 'lib/nrser/types/is.rb', line 31 def initialize value, ** super ** @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
The exact value for this type.
29 30 31 |
# File 'lib/nrser/types/is.rb', line 29 def value @value end |
Instance Method Details
#==(other) ⇒ Object
44 45 46 47 48 |
# File 'lib/nrser/types/is.rb', line 44 def == other equal?(other) || ( self.class.equal?( other.class ) && @value.equal?( other.value ) ) end |
#default_symbolic ⇒ Object
51 52 53 |
# File 'lib/nrser/types/is.rb', line 51 def default_symbolic "{#{ value.inspect }}" end |
#explain ⇒ Object
36 37 38 |
# File 'lib/nrser/types/is.rb', line 36 def explain "Is<#{ value.inspect }>" end |
#test?(value) ⇒ Boolean
40 41 42 |
# File 'lib/nrser/types/is.rb', line 40 def test? value @value.equal? value end |