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.



8114
8115
8116
8117
# File 'lib/syntax_tree/node.rb', line 8114

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

Instance Attribute Details

#nameObject (readonly)

Ident

the name of the parameter



8109
8110
8111
# File 'lib/syntax_tree/node.rb', line 8109

def name
  @name
end

#valueObject (readonly)

nil | untyped

the value of the parameter



8112
8113
8114
# File 'lib/syntax_tree/node.rb', line 8112

def value
  @value
end

Instance Method Details

#commentsObject



8119
8120
8121
# File 'lib/syntax_tree/node.rb', line 8119

def comments
  []
end

#format(q) ⇒ Object



8123
8124
8125
8126
8127
8128
8129
8130
# File 'lib/syntax_tree/node.rb', line 8123

def format(q)
  q.format(name)

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