Class: SyntaxTree::HshPtn::KeywordFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ KeywordFormatter

Returns a new instance of KeywordFormatter.



4458
4459
4460
4461
# File 'lib/syntax_tree/node.rb', line 4458

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

Instance Attribute Details

#keyObject (readonly)

Label

the keyword being used



4453
4454
4455
# File 'lib/syntax_tree/node.rb', line 4453

def key
  @key
end

#valueObject (readonly)

untyped

the optional value for the keyword



4456
4457
4458
# File 'lib/syntax_tree/node.rb', line 4456

def value
  @value
end

Instance Method Details

#commentsObject



4463
4464
4465
# File 'lib/syntax_tree/node.rb', line 4463

def comments
  []
end

#format(q) ⇒ Object



4467
4468
4469
4470
4471
4472
4473
4474
# File 'lib/syntax_tree/node.rb', line 4467

def format(q)
  q.format(key)

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