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.



6804
6805
6806
6807
# File 'lib/syntax_tree/node.rb', line 6804

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

Instance Attribute Details

#nameObject (readonly)

Ident

the name of the parameter



6799
6800
6801
# File 'lib/syntax_tree/node.rb', line 6799

def name
  @name
end

#valueObject (readonly)

nil | untyped

the value of the parameter



6802
6803
6804
# File 'lib/syntax_tree/node.rb', line 6802

def value
  @value
end

Instance Method Details

#commentsObject



6809
6810
6811
# File 'lib/syntax_tree/node.rb', line 6809

def comments
  []
end

#format(q) ⇒ Object



6813
6814
6815
6816
6817
6818
6819
6820
# File 'lib/syntax_tree/node.rb', line 6813

def format(q)
  q.format(name)

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