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.



8231
8232
8233
8234
# File 'lib/syntax_tree/node.rb', line 8231

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

Instance Attribute Details

#nameObject (readonly)

Ident

the name of the parameter



8226
8227
8228
# File 'lib/syntax_tree/node.rb', line 8226

def name
  @name
end

#valueObject (readonly)

nil | Node

the value of the parameter



8229
8230
8231
# File 'lib/syntax_tree/node.rb', line 8229

def value
  @value
end

Instance Method Details

#commentsObject



8236
8237
8238
# File 'lib/syntax_tree/node.rb', line 8236

def comments
  []
end

#format(q) ⇒ Object



8240
8241
8242
8243
8244
8245
8246
8247
# File 'lib/syntax_tree/node.rb', line 8240

def format(q)
  q.format(name)

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