Class: SyntaxTree::Undef
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Undef
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Undef represents the use of the undef keyword.
undef method
Defined Under Namespace
Classes: UndefArgumentFormatter
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#symbols ⇒ Object
readonly
- Array[ DynaSymbol | SymbolLiteral ]
-
the symbols to undefine.
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(symbols:, location:) ⇒ Undef
11088
11089
11090
11091
11092
|
# File 'lib/syntax_tree/node.rb', line 11088
def initialize(symbols:, location:)
@symbols = symbols
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11086
11087
11088
|
# File 'lib/syntax_tree/node.rb', line 11086
def
end
|
#symbols ⇒ Object
- Array[ DynaSymbol | SymbolLiteral ]
-
the symbols to undefine
11083
11084
11085
|
# File 'lib/syntax_tree/node.rb', line 11083
def symbols
@symbols
end
|
Instance Method Details
#===(other) ⇒ Object
11131
11132
11133
|
# File 'lib/syntax_tree/node.rb', line 11131
def ===(other)
other.is_a?(Undef) && ArrayMatch.call(symbols, other.symbols)
end
|
#accept(visitor) ⇒ Object
11094
11095
11096
|
# File 'lib/syntax_tree/node.rb', line 11094
def accept(visitor)
visitor.visit_undef(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11098
11099
11100
|
# File 'lib/syntax_tree/node.rb', line 11098
def child_nodes
symbols
end
|
#copy(symbols: nil, location: nil) ⇒ Object
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
|
# File 'lib/syntax_tree/node.rb', line 11102
def copy(symbols: nil, location: nil)
node =
Undef.new(
symbols: symbols || self.symbols,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
11115
11116
11117
|
# File 'lib/syntax_tree/node.rb', line 11115
def deconstruct_keys(_keys)
{ symbols: symbols, location: location, comments: }
end
|
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
|
# File 'lib/syntax_tree/node.rb', line 11119
def format(q)
keyword = "undef "
formatters = symbols.map { |symbol| UndefArgumentFormatter.new(symbol) }
q.group do
q.text(keyword)
q.nest(keyword.length) do
q.seplist(formatters) { |formatter| q.format(formatter) }
end
end
end
|