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.



6549
6550
6551
6552
# File 'lib/syntax_tree.rb', line 6549

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

Instance Attribute Details

#keyObject (readonly)

Label

the keyword being used



6544
6545
6546
# File 'lib/syntax_tree.rb', line 6544

def key
  @key
end

#valueObject (readonly)

untyped

the optional value for the keyword



6547
6548
6549
# File 'lib/syntax_tree.rb', line 6547

def value
  @value
end

Instance Method Details

#classObject

This is here so that when checking if its contained within a parent pattern that it will return true.



6556
6557
6558
# File 'lib/syntax_tree.rb', line 6556

def class
  HshPtn
end

#commentsObject



6560
6561
6562
# File 'lib/syntax_tree.rb', line 6560

def comments
  []
end

#format(q) ⇒ Object



6564
6565
6566
6567
6568
6569
6570
6571
# File 'lib/syntax_tree.rb', line 6564

def format(q)
  q.format(key)

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