Class: Solargraph::TypeChecker::ParamDef

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/type_checker/param_def.rb

Overview

Data about a method parameter definition. This is the information from the args list in the def call, not the `@param` tags.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type) ⇒ ParamDef

Returns a new instance of ParamDef


13
14
15
16
# File 'lib/solargraph/type_checker/param_def.rb', line 13

def initialize name, type
  @name = name
  @type = type
end

Instance Attribute Details

#nameString (readonly)

Returns:

  • (String)

8
9
10
# File 'lib/solargraph/type_checker/param_def.rb', line 8

def name
  @name
end

#typeSymbol (readonly)

Returns:

  • (Symbol)

11
12
13
# File 'lib/solargraph/type_checker/param_def.rb', line 11

def type
  @type
end

Class Method Details

.from(pin) ⇒ Array<ParamDef>

Get an array of ParamDefs from a method pin.

Parameters:

Returns:


23
24
25
26
27
28
29
# File 'lib/solargraph/type_checker/param_def.rb', line 23

def from pin
  result = []
  pin.parameters.each_with_index do |full, index|
    result.push ParamDef.new(pin.parameter_names[index], arg_type(full))
  end
  result
end