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



6999
7000
7001
7002
# File 'lib/syntax_tree/node.rb', line 6999

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

Instance Attribute Details

#nameObject (readonly)

Ident

the name of the parameter



6994
6995
6996
# File 'lib/syntax_tree/node.rb', line 6994

def name
  @name
end

#valueObject (readonly)

nil | untyped

the value of the parameter



6997
6998
6999
# File 'lib/syntax_tree/node.rb', line 6997

def value
  @value
end

Instance Method Details

#commentsObject



7004
7005
7006
# File 'lib/syntax_tree/node.rb', line 7004

def comments
  []
end

#format(q) ⇒ Object



7008
7009
7010
7011
7012
7013
7014
7015
# File 'lib/syntax_tree/node.rb', line 7008

def format(q)
  q.format(name)

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