Class: SyntaxTree::Undef::UndefArgumentFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

Undef accepts a variable number of arguments that can be either DynaSymbol or SymbolLiteral objects. For SymbolLiteral objects we descend directly into the value in order to have it come out as bare words.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ UndefArgumentFormatter

Returns a new instance of UndefArgumentFormatter.



9335
9336
9337
# File 'lib/syntax_tree/node.rb', line 9335

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

DynaSymbol | SymbolLiteral

the symbol to undefine



9333
9334
9335
# File 'lib/syntax_tree/node.rb', line 9333

def node
  @node
end

Instance Method Details

#commentsObject



9339
9340
9341
9342
9343
9344
9345
# File 'lib/syntax_tree/node.rb', line 9339

def comments
  if node.is_a?(SymbolLiteral)
    node.comments + node.value.comments
  else
    node.comments
  end
end

#format(q) ⇒ Object



9347
9348
9349
# File 'lib/syntax_tree/node.rb', line 9347

def format(q)
  node.is_a?(SymbolLiteral) ? q.format(node.value) : q.format(node)
end