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



1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
# File 'lib/syntax_tree/node.rb', line 1788

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