Class: NRSER::Types::Top

Inherits:
Type show all
Defined in:
lib/nrser/types/top.rb

Overview

The top type is the universal type - all values are members.

Constant Summary collapse

NAME =
'*'

Instance Method Summary collapse

Methods inherited from Type

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

Constructor Details

#initializeTop

Returns a new instance of Top.



31
32
33
# File 'lib/nrser/types/top.rb', line 31

def initialize
  super name: NAME
end

Instance Method Details

#==(other) ⇒ Boolean

Note:

‘other`’s class must be AnyType exactly - we make no assumptions about anything that has subclasses AnyType.

AnyType instances are all equal.

Parameters:

  • other (*)

    Object to compare to.

Returns:

  • (Boolean)

    ‘true` if `other#class` equals AnyType.



68
69
70
# File 'lib/nrser/types/top.rb', line 68

def == other
  other.class == Top
end

#explainObject



39
40
41
# File 'lib/nrser/types/top.rb', line 39

def explain
  'Top'
end

#from_s(string) ⇒ Object



51
52
53
# File 'lib/nrser/types/top.rb', line 51

def from_s string
  string
end

#has_from_s?Boolean

Returns:



47
48
49
# File 'lib/nrser/types/top.rb', line 47

def has_from_s?
  true
end

#symbolicObject



43
44
45
# File 'lib/nrser/types/top.rb', line 43

def symbolic
  '*' # '⊤'
end

#test?(value) ⇒ Boolean

Returns:



35
36
37
# File 'lib/nrser/types/top.rb', line 35

def test? value
  true
end