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.



11215
11216
11217
# File 'lib/syntax_tree/node.rb', line 11215

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

DynaSymbol | SymbolLiteral

the symbol to undefine



11213
11214
11215
# File 'lib/syntax_tree/node.rb', line 11213

def node
  @node
end

Instance Method Details

#commentsObject



11219
11220
11221
11222
11223
11224
11225
# File 'lib/syntax_tree/node.rb', line 11219

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

#format(q) ⇒ Object



11227
11228
11229
# File 'lib/syntax_tree/node.rb', line 11227

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