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.



6719
6720
6721
6722
# File 'lib/syntax_tree/node.rb', line 6719

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

Instance Attribute Details

#nameObject (readonly)

Ident

the name of the parameter



6714
6715
6716
# File 'lib/syntax_tree/node.rb', line 6714

def name
  @name
end

#valueObject (readonly)

nil | untyped

the value of the parameter



6717
6718
6719
# File 'lib/syntax_tree/node.rb', line 6717

def value
  @value
end

Instance Method Details

#commentsObject



6724
6725
6726
# File 'lib/syntax_tree/node.rb', line 6724

def comments
  []
end

#format(q) ⇒ Object



6728
6729
6730
6731
6732
6733
6734
6735
# File 'lib/syntax_tree/node.rb', line 6728

def format(q)
  q.format(name)

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