Class: Code::Type::Maybe
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Code::Type
#max_arguments_of, #min_arguments_of, #valid_for?
Constructor Details
#initialize(clazz) ⇒ Maybe
Returns a new instance of Maybe.
8
9
10
|
# File 'lib/code/type/maybe.rb', line 8
def initialize(clazz)
@clazz = clazz
end
|
Instance Attribute Details
Returns the value of attribute clazz.
6
7
8
|
# File 'lib/code/type/maybe.rb', line 6
def clazz
@clazz
end
|
Instance Method Details
#max_arguments ⇒ Object
20
21
22
|
# File 'lib/code/type/maybe.rb', line 20
def max_arguments
max_arguments_of(clazz)
end
|
#min_arguments ⇒ Object
16
17
18
|
# File 'lib/code/type/maybe.rb', line 16
def min_arguments
0
end
|
24
25
26
|
# File 'lib/code/type/maybe.rb', line 24
def name
"#{clazz.name}.maybe"
end
|
#valid?(argument) ⇒ Boolean
12
13
14
|
# File 'lib/code/type/maybe.rb', line 12
def valid?(argument)
!argument || valid_for?(expected: clazz, actual: argument)
end
|