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
Returns a new instance of Undef.
9085 9086 9087 9088 9089 |
# File 'lib/syntax_tree/node.rb', line 9085 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
9083 9084 9085 |
# File 'lib/syntax_tree/node.rb', line 9083 def comments @comments end |
#symbols ⇒ Object (readonly)
- Array[ DynaSymbol | SymbolLiteral ]
-
the symbols to undefine
9080 9081 9082 |
# File 'lib/syntax_tree/node.rb', line 9080 def symbols @symbols end |
Instance Method Details
#accept(visitor) ⇒ Object
9091 9092 9093 |
# File 'lib/syntax_tree/node.rb', line 9091 def accept(visitor) visitor.visit_undef(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9095 9096 9097 |
# File 'lib/syntax_tree/node.rb', line 9095 def child_nodes symbols end |
#deconstruct_keys(_keys) ⇒ Object
9101 9102 9103 |
# File 'lib/syntax_tree/node.rb', line 9101 def deconstruct_keys(_keys) { symbols: symbols, location: location, comments: comments } end |
#format(q) ⇒ Object
9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 |
# File 'lib/syntax_tree/node.rb', line 9105 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 |