Class: SyntaxTree::Params::KeywordFormatter

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

Overview

Formats the keyword position of the parameters. This includes the label, as well as an optional default value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ KeywordFormatter

Returns a new instance of KeywordFormatter.



6643
6644
6645
6646
# File 'lib/syntax_tree/node.rb', line 6643

def initialize(name, value)
  @name = name
  @value = value
end

Instance Attribute Details

#nameObject (readonly)

Ident

the name of the parameter



6638
6639
6640
# File 'lib/syntax_tree/node.rb', line 6638

def name
  @name
end

#valueObject (readonly)

nil | untyped

the value of the parameter



6641
6642
6643
# File 'lib/syntax_tree/node.rb', line 6641

def value
  @value
end

Instance Method Details

#commentsObject



6648
6649
6650
# File 'lib/syntax_tree/node.rb', line 6648

def comments
  []
end

#format(q) ⇒ Object



6652
6653
6654
6655
6656
6657
6658
6659
# File 'lib/syntax_tree/node.rb', line 6652

def format(q)
  q.format(name)

  if value
    q.text(" ")
    q.format(value)
  end
end