Class: NRSER::Types::Top
Overview
The top type is the universal type - all values are members.
Constant Summary collapse
- NAME =
'*'
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
AnyType instances are all equal.
- #explain ⇒ Object
- #from_s(string) ⇒ Object
- #has_from_s? ⇒ Boolean
-
#initialize ⇒ Top
constructor
A new instance of Top.
- #symbolic ⇒ Object
- #test?(value) ⇒ Boolean
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
#initialize ⇒ Top
Returns a new instance of Top.
31 32 33 34 35 36 37 38 |
# File 'lib/nrser/types/top.rb', line 31 def initialize super name: NAME # All types maybe *should* be frozen so they can be used as prop defaults, # but this is the first one I ran into in practice, so it's the first one # to freeze. freeze 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.
73 74 75 |
# File 'lib/nrser/types/top.rb', line 73 def == other other.class == Top end |
#explain ⇒ Object
44 45 46 |
# File 'lib/nrser/types/top.rb', line 44 def explain 'Top' end |
#from_s(string) ⇒ Object
56 57 58 |
# File 'lib/nrser/types/top.rb', line 56 def from_s string string end |
#symbolic ⇒ Object
48 49 50 |
# File 'lib/nrser/types/top.rb', line 48 def symbolic '*' # '⊤' end |