Class: SyntaxTree::Undef
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
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(symbols:, location:, comments: []) ⇒ Undef
constructor
A new instance of Undef.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(symbols:, location:, comments: []) ⇒ Undef
9124 9125 9126 9127 9128 |
# File 'lib/syntax_tree/node.rb', line 9124 def initialize(symbols:, location:, comments: []) @symbols = symbols @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9122 9123 9124 |
# File 'lib/syntax_tree/node.rb', line 9122 def comments @comments end |
#symbols ⇒ Object (readonly)
- Array[ DynaSymbol | SymbolLiteral ]
-
the symbols to undefine
9119 9120 9121 |
# File 'lib/syntax_tree/node.rb', line 9119 def symbols @symbols end |
Instance Method Details
#accept(visitor) ⇒ Object
9130 9131 9132 |
# File 'lib/syntax_tree/node.rb', line 9130 def accept(visitor) visitor.visit_undef(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9134 9135 9136 |
# File 'lib/syntax_tree/node.rb', line 9134 def child_nodes symbols end |
#deconstruct_keys(_keys) ⇒ Object
9140 9141 9142 |
# File 'lib/syntax_tree/node.rb', line 9140 def deconstruct_keys(_keys) { symbols: symbols, location: location, comments: comments } end |
#format(q) ⇒ Object
9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 |
# File 'lib/syntax_tree/node.rb', line 9144 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 |