Class: SyntaxTree::KwRestParam

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

KwRestParam represents defining a parameter in a method definition that accepts all remaining keyword parameters.

def method(**kwargs) end

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(name:, location:, comments: []) ⇒ KwRestParam

Returns a new instance of KwRestParam.



6042
6043
6044
6045
6046
# File 'lib/syntax_tree/node.rb', line 6042

def initialize(name:, location:, comments: [])
  @name = name
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



6040
6041
6042
# File 'lib/syntax_tree/node.rb', line 6040

def comments
  @comments
end

#nameObject (readonly)

nil | Ident

the name of the parameter



6037
6038
6039
# File 'lib/syntax_tree/node.rb', line 6037

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object



6048
6049
6050
# File 'lib/syntax_tree/node.rb', line 6048

def accept(visitor)
  visitor.visit_kwrest_param(self)
end

#child_nodesObject Also known as: deconstruct



6052
6053
6054
# File 'lib/syntax_tree/node.rb', line 6052

def child_nodes
  [name]
end

#deconstruct_keys(_keys) ⇒ Object



6058
6059
6060
# File 'lib/syntax_tree/node.rb', line 6058

def deconstruct_keys(_keys)
  { name: name, location: location, comments: comments }
end

#format(q) ⇒ Object



6062
6063
6064
6065
# File 'lib/syntax_tree/node.rb', line 6062

def format(q)
  q.text("**")
  q.format(name) if name
end