Class: Steep::TypeInference::BlockParams::MultipleParam
- Defined in:
- lib/steep/type_inference/block_params.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #each_param(&block) ⇒ Object
- #hash ⇒ Object
-
#initialize(node:, params:) ⇒ MultipleParam
constructor
A new instance of MultipleParam.
- #type ⇒ Object
- #variable_types ⇒ Object
Constructor Details
#initialize(node:, params:) ⇒ MultipleParam
Returns a new instance of MultipleParam.
41 42 43 44 |
# File 'lib/steep/type_inference/block_params.rb', line 41 def initialize(node:, params:) @params = params @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
37 38 39 |
# File 'lib/steep/type_inference/block_params.rb', line 37 def node @node end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
39 40 41 |
# File 'lib/steep/type_inference/block_params.rb', line 39 def params @params end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
46 47 48 49 50 |
# File 'lib/steep/type_inference/block_params.rb', line 46 def ==(other) other.is_a?(self.class) && other.node == node && other.params == params end |
#each_param(&block) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/steep/type_inference/block_params.rb', line 65 def each_param(&block) if block params.each do |param| case param when Param yield param when MultipleParam param.each_param(&block) end end else enum_for :each_param end end |
#hash ⇒ Object
54 55 56 |
# File 'lib/steep/type_inference/block_params.rb', line 54 def hash self.class.hash ^ node.hash ^ params.hash end |
#type ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/steep/type_inference/block_params.rb', line 80 def type types = params.map do |param| param.type or return end AST::Types::Tuple.new(types: types) end |
#variable_types ⇒ Object
58 59 60 61 62 63 |
# File 'lib/steep/type_inference/block_params.rb', line 58 def variable_types each_param.with_object({}) do |param, hash| #$ Hash[Symbol, AST::Types::t?] var_name = param.var || next hash[var_name] = param.type end end |