Class: Steep::TypeInference::MethodParams::BlockParameter
- Defined in:
- lib/steep/type_inference/method_params.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#self_type ⇒ Object
readonly
Returns the value of attribute self_type.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, type:, node:, optional:, self_type:) ⇒ BlockParameter
constructor
A new instance of BlockParameter.
- #optional? ⇒ Boolean
- #var_type ⇒ Object
Constructor Details
#initialize(name:, type:, node:, optional:, self_type:) ⇒ BlockParameter
Returns a new instance of BlockParameter.
100 101 102 103 104 105 106 |
# File 'lib/steep/type_inference/method_params.rb', line 100 def initialize(name:, type:, node:, optional:, self_type:) @name = name @type = type @node = node @optional = optional @self_type = self_type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
95 96 97 |
# File 'lib/steep/type_inference/method_params.rb', line 95 def name @name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
97 98 99 |
# File 'lib/steep/type_inference/method_params.rb', line 97 def node @node end |
#self_type ⇒ Object (readonly)
Returns the value of attribute self_type.
98 99 100 |
# File 'lib/steep/type_inference/method_params.rb', line 98 def self_type @self_type end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
96 97 98 |
# File 'lib/steep/type_inference/method_params.rb', line 96 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
126 127 128 129 130 131 132 133 |
# File 'lib/steep/type_inference/method_params.rb', line 126 def ==(other) other.class == self.class && other.name == name && other.type == type && other.node == node && other.optional? == optional? && other.self_type == self_type end |
#hash ⇒ Object
137 138 139 |
# File 'lib/steep/type_inference/method_params.rb', line 137 def hash self.class.hash ^ name.hash ^ type.hash ^ node.hash ^ optional?.hash ^ self_type.hash end |
#optional? ⇒ Boolean
108 109 110 |
# File 'lib/steep/type_inference/method_params.rb', line 108 def optional? @optional ? true : false end |
#var_type ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/steep/type_inference/method_params.rb', line 112 def var_type if type proc_type = AST::Types::Proc.new(type: type, block: nil, self_type: self_type) if optional? AST::Types::Union.build(types: [proc_type, AST::Builtin.nil_type]) else proc_type end else AST::Builtin.nil_type end end |