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
Constructor Details
#initialize(symbols:, location:, comments: []) ⇒ Undef
Returns a new instance of Undef.
8292 8293 8294 8295 8296 |
# File 'lib/syntax_tree/node.rb', line 8292 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
8290 8291 8292 |
# File 'lib/syntax_tree/node.rb', line 8290 def comments @comments end |
#symbols ⇒ Object (readonly)
- Array[ DynaSymbol | SymbolLiteral ]
-
the symbols to undefine
8287 8288 8289 |
# File 'lib/syntax_tree/node.rb', line 8287 def symbols @symbols end |
Instance Method Details
#accept(visitor) ⇒ Object
8298 8299 8300 |
# File 'lib/syntax_tree/node.rb', line 8298 def accept(visitor) visitor.visit_undef(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8302 8303 8304 |
# File 'lib/syntax_tree/node.rb', line 8302 def child_nodes symbols end |
#deconstruct_keys(keys) ⇒ Object
8308 8309 8310 |
# File 'lib/syntax_tree/node.rb', line 8308 def deconstruct_keys(keys) { symbols: symbols, location: location, comments: comments } end |
#format(q) ⇒ Object
8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 |
# File 'lib/syntax_tree/node.rb', line 8312 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 |