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.



4858
4859
4860
4861
# File 'lib/syntax_tree/node.rb', line 4858

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

Instance Attribute Details

#keyObject (readonly)

Label

the keyword being used



4853
4854
4855
# File 'lib/syntax_tree/node.rb', line 4853

def key
  @key
end

#valueObject (readonly)

untyped

the optional value for the keyword



4856
4857
4858
# File 'lib/syntax_tree/node.rb', line 4856

def value
  @value
end

Instance Method Details

#commentsObject



4863
4864
4865
# File 'lib/syntax_tree/node.rb', line 4863

def comments
  []
end

#format(q) ⇒ Object



4867
4868
4869
4870
4871
4872
4873
4874
# File 'lib/syntax_tree/node.rb', line 4867

def format(q)
  q.format(key)

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