Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

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

  • #argument ⇒ Object readonly
    Backref | DynaSymbol | GVar | SymbolLiteral

    the argument being passed to alias.

Instance Method Summary collapse

Constructor Details

#initialize(argument) ⇒ AliasArgumentFormatter

Returns a new instance of AliasArgumentFormatter.



466
467
468
# File 'lib/syntax_tree/node.rb', line 466

def initialize(argument)
  @argument = argument
end

Instance Attribute Details

#argumentObject (readonly)

Backref | DynaSymbol | GVar | SymbolLiteral

the argument being passed

to alias



464
465
466
# File 'lib/syntax_tree/node.rb', line 464

def argument
  @argument
end

Instance Method Details

#commentsObject



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

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

#format(q) ⇒ Object



478
479
480
481
482
483
484
# File 'lib/syntax_tree/node.rb', line 478

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