Class: SyntaxTree::AliasNode::AliasArgumentFormatter

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

Overview

Formats an argument to the alias keyword. For symbol literals it uses the value of the symbol directly to look like bare words.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argument) ⇒ AliasArgumentFormatter

Returns a new instance of AliasArgumentFormatter.



456
457
458
# File 'lib/syntax_tree/node.rb', line 456

def initialize(argument)
  @argument = argument
end

Instance Attribute Details

#argumentObject (readonly)

Backref | DynaSymbol | GVar | SymbolLiteral

the argument being passed

to alias



454
455
456
# File 'lib/syntax_tree/node.rb', line 454

def argument
  @argument
end

Instance Method Details

#commentsObject



460
461
462
463
464
465
466
# File 'lib/syntax_tree/node.rb', line 460

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

#format(q) ⇒ Object



468
469
470
471
472
473
474
# File 'lib/syntax_tree/node.rb', line 468

def format(q)
  if argument.is_a?(SymbolLiteral)
    q.format(argument.value)
  else
    q.format(argument)
  end
end