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.



8190
8191
8192
8193
# File 'lib/syntax_tree/node.rb', line 8190

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

Instance Attribute Details

#nameObject (readonly)

Ident

the name of the parameter



8185
8186
8187
# File 'lib/syntax_tree/node.rb', line 8185

def name
  @name
end

#valueObject (readonly)

nil | Node

the value of the parameter



8188
8189
8190
# File 'lib/syntax_tree/node.rb', line 8188

def value
  @value
end

Instance Method Details

#commentsObject



8195
8196
8197
# File 'lib/syntax_tree/node.rb', line 8195

def comments
  []
end

#format(q) ⇒ Object



8199
8200
8201
8202
8203
8204
8205
8206
# File 'lib/syntax_tree/node.rb', line 8199

def format(q)
  q.format(name)

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