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.



365
366
367
# File 'lib/syntax_tree/node.rb', line 365

def initialize(argument)
  @argument = argument
end

Instance Attribute Details

#argumentObject (readonly)

DynaSymbol | SymbolLiteral

the argument being passed to alias



363
364
365
# File 'lib/syntax_tree/node.rb', line 363

def argument
  @argument
end

Instance Method Details

#commentsObject



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

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

#format(q) ⇒ Object



377
378
379
380
381
382
383
# File 'lib/syntax_tree/node.rb', line 377

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