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.



9051
9052
9053
# File 'lib/syntax_tree/node.rb', line 9051

def initialize(node)
  @node = node
end

Instance Attribute Details

#node ⇒ Object (readonly)

[DynaSymbol | SymbolLiteral] the symbol to undefine



9049
9050
9051
# File 'lib/syntax_tree/node.rb', line 9049

def node
  @node
end

Instance Method Details

#comments ⇒ Object



9055
9056
9057
9058
9059
9060
9061
# File 'lib/syntax_tree/node.rb', line 9055

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

#format(q) ⇒ Object



9063
9064
9065
# File 'lib/syntax_tree/node.rb', line 9063

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