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.



5765
5766
5767
5768
# File 'lib/syntax_tree/node.rb', line 5765

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

Instance Attribute Details

#keyObject (readonly)

Label

the keyword being used



5760
5761
5762
# File 'lib/syntax_tree/node.rb', line 5760

def key
  @key
end

#valueObject (readonly)

untyped

the optional value for the keyword



5763
5764
5765
# File 'lib/syntax_tree/node.rb', line 5763

def value
  @value
end

Instance Method Details

#commentsObject



5770
5771
5772
# File 'lib/syntax_tree/node.rb', line 5770

def comments
  []
end

#format(q) ⇒ Object



5774
5775
5776
5777
5778
5779
5780
5781
# File 'lib/syntax_tree/node.rb', line 5774

def format(q)
  q.format(key)

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