class Solargraph::Convention::StructDefinition::StructAssignmentNode
A node wrapper for a Struct definition via const assignment. @example
MyStruct = Struct.new(:bar, :baz) do def foo end end
Public Class Methods
Source
# File lib/solargraph/convention/struct_definition/struct_assignment_node.rb, line 26 def match?(node) return false unless node&.type == :casgn return false if node.children[2].nil? struct_node = if node.children[2].type == :block node.children[2].children[0] else node.children[2] end struct_definition_node?(struct_node) end
@example s(:casgn, nil, :Foo,
s(:block,
s(:send,
s(:const, nil, :Struct), :new,
s(:sym, :bar),
s(:sym, :baz)),
s(:args),
s(:def, :foo,
s(:args),
s(:send, nil, :bar))))
@param node [Parser::AST::Node]
Public Instance Methods
Source
# File lib/solargraph/convention/struct_definition/struct_assignment_node.rb, line 40 def class_name if node.children[0] Parser::NodeMethods.unpack_name(node.children[0]) + "::#{node.children[1]}" else node.children[1].to_s end end
Private Instance Methods
Source
# File lib/solargraph/convention/struct_definition/struct_assignment_node.rb, line 51 def struct_node if node.children[2].type == :block node.children[2].children[0] else node.children[2] end end
@return [Parser::AST::Node]