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.
8853 8854 8855 8856 8857 |
# File 'lib/syntax_tree/node.rb', line 8853 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
8851 8852 8853 |
# File 'lib/syntax_tree/node.rb', line 8851 def comments @comments end |
#symbols ⇒ Object (readonly)
- Array[ DynaSymbol | SymbolLiteral ]
-
the symbols to undefine
8848 8849 8850 |
# File 'lib/syntax_tree/node.rb', line 8848 def symbols @symbols end |
Instance Method Details
#accept(visitor) ⇒ Object
8859 8860 8861 |
# File 'lib/syntax_tree/node.rb', line 8859 def accept(visitor) visitor.visit_undef(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8863 8864 8865 |
# File 'lib/syntax_tree/node.rb', line 8863 def child_nodes symbols end |
#deconstruct_keys(keys) ⇒ Object
8869 8870 8871 |
# File 'lib/syntax_tree/node.rb', line 8869 def deconstruct_keys(keys) { symbols: symbols, location: location, comments: comments } end |
#format(q) ⇒ Object
8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 |
# File 'lib/syntax_tree/node.rb', line 8873 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 |