Class: SyntaxTree::Alias::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.



355
356
357
# File 'lib/syntax_tree/node.rb', line 355

def initialize(argument)
  @argument = argument
end

Instance Attribute Details

#argumentObject (readonly)

DynaSymbol | SymbolLiteral

the argument being passed to alias



353
354
355
# File 'lib/syntax_tree/node.rb', line 353

def argument
  @argument
end

Instance Method Details

#commentsObject



359
360
361
362
363
364
365
# File 'lib/syntax_tree/node.rb', line 359

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

#format(q) ⇒ Object



367
368
369
370
371
372
373
# File 'lib/syntax_tree/node.rb', line 367

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