Class: Steep::TypeInference::MethodParams::BaseParameter
- Inherits:
-
Object
- Object
- Steep::TypeInference::MethodParams::BaseParameter
show all
- Defined in:
- lib/steep/type_inference/method_params.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name:, type:, node:) ⇒ BaseParameter
Returns a new instance of BaseParameter.
9
10
11
12
13
|
# File 'lib/steep/type_inference/method_params.rb', line 9
def initialize(name:, type:, node:)
@name = name
@type = type
@node = node
end
|
Instance Attribute Details
Returns the value of attribute name.
5
6
7
|
# File 'lib/steep/type_inference/method_params.rb', line 5
def name
@name
end
|
Returns the value of attribute node.
7
8
9
|
# File 'lib/steep/type_inference/method_params.rb', line 7
def node
@node
end
|
Returns the value of attribute type.
6
7
8
|
# File 'lib/steep/type_inference/method_params.rb', line 6
def type
@type
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
39
40
41
42
43
44
45
|
# File 'lib/steep/type_inference/method_params.rb', line 39
def ==(other)
other.class == self.class &&
other.name == name &&
other.type == type &&
other.value == value &&
other.node == node
end
|
49
50
51
|
# File 'lib/steep/type_inference/method_params.rb', line 49
def hash
self.class.hash ^ name.hash ^ type.hash ^ value.hash ^ node.hash
end
|
#optional? ⇒ Boolean
15
16
17
18
19
20
21
22
|
# File 'lib/steep/type_inference/method_params.rb', line 15
def optional?
case node.type
when :optarg, :kwoptarg
true
else
false
end
end
|
#untyped? ⇒ Boolean
35
36
37
|
# File 'lib/steep/type_inference/method_params.rb', line 35
def untyped?
!type
end
|
24
25
26
27
28
29
|
# File 'lib/steep/type_inference/method_params.rb', line 24
def value
case node.type
when :optarg, :kwoptarg
node.children[1]
end
end
|
31
32
33
|
# File 'lib/steep/type_inference/method_params.rb', line 31
def var_type
type || AST::Builtin.any_type
end
|