Class: Code::Type
- Inherits:
-
Object
show all
- Defined in:
- lib/code/type.rb,
lib/code/type/or.rb,
lib/code/type/sig.rb,
lib/code/type/hash.rb,
lib/code/type/maybe.rb,
lib/code/type/repeat.rb
Defined Under Namespace
Classes: Hash, Maybe, Or, Repeat, Sig
Instance Method Summary
collapse
Instance Method Details
#max_arguments_of(clazz) ⇒ Object
21
22
23
|
# File 'lib/code/type.rb', line 21
def max_arguments_of(clazz)
clazz.is_a?(Type) ? clazz.max_arguments : 1
end
|
#min_arguments_of(clazz) ⇒ Object
17
18
19
|
# File 'lib/code/type.rb', line 17
def min_arguments_of(clazz)
clazz.is_a?(Type) ? clazz.min_arguments : 1
end
|
5
6
7
|
# File 'lib/code/type.rb', line 5
def name
raise NotImplementedError, "#{self.class}#name"
end
|
#valid?(argument) ⇒ Boolean
9
10
11
|
# File 'lib/code/type.rb', line 9
def valid?(argument)
raise NotImplementedError, "#{self.class}#valid?"
end
|
#valid_for?(expected:, actual:) ⇒ Boolean
13
14
15
|
# File 'lib/code/type.rb', line 13
def valid_for?(expected:, actual:)
expected.is_a?(Type) ? expected.valid?(actual) : actual.is_a?(expected)
end
|