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.

Parameters:

  • name (String)
  • type (Symbol)

    The type of parameter, such as :req, :opt, :rest, etc.



17
18
19
20
# File 'lib/solargraph/type_checker/param_def.rb', line 17

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

Instance Attribute Details

#nameString (readonly)

Returns:

  • (String)


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

def name
  @name
end

#typeSymbol (readonly)

Returns:

  • (Symbol)


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

def type
  @type
end

Class Method Details

.from(pin) ⇒ Array<ParamDef>

Get an array of ParamDefs from a method pin.

Parameters:

Returns:



27
28
29
30
31
32
33
# File 'lib/solargraph/type_checker/param_def.rb', line 27

def from pin
  result = []
  pin.parameters.each do |par|
    result.push ParamDef.new(par.name, par.decl)
  end
  result
end