Class: SyntaxTree::HashKeyFormatter::Rockets

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

Overview

Formats the keys of a hash literal using hash rockets.

Instance Method Summary collapse

Instance Method Details

#format_key(q, key) ⇒ Object



1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
# File 'lib/syntax_tree/node.rb', line 1757

def format_key(q, key)
  case key
  when Label
    q.text(":#{key.value.chomp(":")}")
  when DynaSymbol
    q.text(":")
    q.format(key)
  else
    q.format(key)
  end

  q.text(" =>")
end