Class: NRSER::Types::Equivalent
- Defined in:
- lib/nrser/types/eqiuvalent.rb
Overview
Type satisfied only by anything ‘#==` it’s #value.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Attributes ========================================================================.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #default_symbolic ⇒ Object
- #explain ⇒ Object
-
#initialize(value, **options) ⇒ Equivalent
constructor
A new instance of Equivalent.
- #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) ⇒ Equivalent
Returns a new instance of Equivalent.
32 33 34 35 |
# File 'lib/nrser/types/eqiuvalent.rb', line 32 def initialize value, ** super ** @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Attributes
30 31 32 |
# File 'lib/nrser/types/eqiuvalent.rb', line 30 def value @value end |
Instance Method Details
#==(other) ⇒ Object
48 49 50 51 52 |
# File 'lib/nrser/types/eqiuvalent.rb', line 48 def == other equal?(other) || ( self.class == other.class && @value == other.value ) end |
#default_symbolic ⇒ Object
55 56 57 |
# File 'lib/nrser/types/eqiuvalent.rb', line 55 def default_symbolic "{ x : #{ value.inspect }==x }" end |
#explain ⇒ Object
38 39 40 |
# File 'lib/nrser/types/eqiuvalent.rb', line 38 def explain "Equivalent<#{ value.inspect }>" end |
#test?(value) ⇒ Boolean
43 44 45 |
# File 'lib/nrser/types/eqiuvalent.rb', line 43 def test? value @value.equal? value end |