Class: Camille::BasicType
- Inherits:
-
Object
- Object
- Camille::BasicType
show all
- Defined in:
- lib/camille/basic_type.rb
Overview
This class specifies the methods available for all types includeing built-in and custom ones.
Direct Known Subclasses
PickAndOmit, Type, Types::Any, Types::Array, Types::Boolean, Types::BooleanLiteral, Types::Intersection, Types::Null, Types::Number, Types::NumberLiteral, Types::Object, Types::Record, Types::String, Types::StringLiteral, Types::Tuple, Types::Undefined, Types::Union
Defined Under Namespace
Modules: CheckRendered
Classes: InvalidTypeError
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BasicType.
24
25
26
|
# File 'lib/camille/basic_type.rb', line 24
def initialize
@fingerprint = Digest::MD5.hexdigest self.class.name
end
|
Instance Attribute Details
#fingerprint ⇒ Object
Returns the value of attribute fingerprint.
22
23
24
|
# File 'lib/camille/basic_type.rb', line 22
def fingerprint
@fingerprint
end
|
Class Method Details
.&(other) ⇒ Object
52
53
54
|
# File 'lib/camille/basic_type.rb', line 52
def self.& other
Camille::Type.instance(self) & other
end
|
.[] ⇒ Object
56
57
58
|
# File 'lib/camille/basic_type.rb', line 56
def self.[]
Camille::Type.instance(self)[]
end
|
.directly_instantiable? ⇒ Boolean
60
61
62
|
# File 'lib/camille/basic_type.rb', line 60
def self.directly_instantiable?
instance_method(:initialize).arity == 0
end
|
.inherited(klass) ⇒ Object
64
65
66
|
# File 'lib/camille/basic_type.rb', line 64
def self.inherited klass
klass.prepend CheckRendered
end
|
.instance(value) ⇒ Object
.|(other) ⇒ Object
48
49
50
|
# File 'lib/camille/basic_type.rb', line 48
def self.| other
Camille::Type.instance(self) | other
end
|
Instance Method Details
#check(value) ⇒ Object
40
41
42
|
# File 'lib/camille/basic_type.rb', line 40
def check value
raise NotImplementedError
end
|
44
45
46
|
# File 'lib/camille/basic_type.rb', line 44
def transform value
value
end
|
#|(other) ⇒ Object
28
29
30
|
# File 'lib/camille/basic_type.rb', line 28
def | other
Camille::Types::Union.new(self, other)
end
|