Class: Finitio::Type
Overview
Abstract class for Finitio type (generators).
Direct Known Subclasses
AdType, AliasType, AnyType, BuiltinType, HighOrderType, MultiRelationType, MultiTupleType, ProxyType, RelationType, SeqType, SetType, StructType, SubType, TupleType, UnionType
Constant Summary
Constants included
from Metadata
Metadata::EMPTY_METADATA
Instance Method Summary
collapse
Methods included from Metadata
#metadata, #metadata=, #metadata?
Constructor Details
#initialize(name, metadata) ⇒ Type
Returns a new instance of Type.
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/finitio/type.rb', line 8
def initialize(name, metadata)
unless name.nil? or name.is_a?(String)
raise ArgumentError, "String expected for type name, got `#{name}`"
end
unless metadata.nil? or metadata.is_a?(Hash)
raise ArgumentError, "Hash expected for metadata, got `#{metadata}`"
end
@name = name
@metadata = metadata
end
|
Instance Method Details
#==(other) ⇒ Object
77
78
79
80
81
|
# File 'lib/finitio/type.rb', line 77
def ==(other)
super || [ProxyType, AliasType].any?{|t|
other.is_a?(t) && other == self
}
end
|
#anonymous? ⇒ Boolean
19
20
21
|
# File 'lib/finitio/type.rb', line 19
def anonymous?
@name.nil?
end
|
#default_name ⇒ Object
27
28
29
|
# File 'lib/finitio/type.rb', line 27
def default_name
raise NotImplementedError, "Missing #{self.class.name}#default_name"
end
|
#dress(*args) ⇒ Object
55
56
57
|
# File 'lib/finitio/type.rb', line 55
def dress(*args)
raise NotImplementedError, "Missing #{self.class.name}#dress"
end
|
#include?(value) ⇒ Boolean
Check if ‘value` belongs to this type. Returns true if it’s the case, false otherwise.
For belonging to the type, ‘value` MUST be a valid representation, not an ’approximation’ or some ‘similar’ representation. In particular, returning true means that no dressing is required for using ‘value` as a proper one. Similarly, the method MUST always return true on a value directly obtained through `dress`.
51
52
53
|
# File 'lib/finitio/type.rb', line 51
def include?(value)
raise NotImplementedError, "Missing #{self.class.name}#include?"
end
|
#name ⇒ Object
31
32
33
|
# File 'lib/finitio/type.rb', line 31
def name
@name || default_name
end
|
#name=(n, force = false) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/finitio/type.rb', line 35
def name=(n, force = false)
if !@name.nil? && !force
raise Error, "Name already set to `#{@name}` on #{self.class}"
end
@name = n
end
|
#named? ⇒ Boolean
23
24
25
|
# File 'lib/finitio/type.rb', line 23
def named?
!anonymous?
end
|
#resolve_proxies(system) ⇒ Object
83
84
85
|
# File 'lib/finitio/type.rb', line 83
def resolve_proxies(system)
raise NotImplementedError, "resolve_proxies must be overriden"
end
|
#suppremum(other) ⇒ Object
59
60
61
62
|
# File 'lib/finitio/type.rb', line 59
def suppremum(other)
return self if other == self
other._suppremum(self)
end
|
#to_s ⇒ Object
73
74
75
|
# File 'lib/finitio/type.rb', line 73
def to_s
name.to_s
end
|
#unconstrained ⇒ Object
69
70
71
|
# File 'lib/finitio/type.rb', line 69
def unconstrained
self
end
|