Class: SyntaxTree::HshPtn::KeywordFormatter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ KeywordFormatter

Returns a new instance of KeywordFormatter.



6596
6597
6598
6599
# File 'lib/syntax_tree.rb', line 6596

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

Instance Attribute Details

#keyObject (readonly)

Label

the keyword being used



6591
6592
6593
# File 'lib/syntax_tree.rb', line 6591

def key
  @key
end

#valueObject (readonly)

untyped

the optional value for the keyword



6594
6595
6596
# File 'lib/syntax_tree.rb', line 6594

def value
  @value
end

Instance Method Details

#commentsObject



6601
6602
6603
# File 'lib/syntax_tree.rb', line 6601

def comments
  []
end

#format(q) ⇒ Object



6605
6606
6607
6608
6609
6610
6611
6612
# File 'lib/syntax_tree.rb', line 6605

def format(q)
  q.format(key)

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