Class: SyntaxTree::HashKeyFormatter::Labels

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

Overview

Formats the keys of a hash literal using labels.

Constant Summary collapse

LABEL =
/\A[A-Za-z_](\w*[\w!?])?\z/

Instance Method Summary collapse

Instance Method Details

#format_key(q, key) ⇒ Object



1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
# File 'lib/syntax_tree/node.rb', line 1393

def format_key(q, key)
  case key
  in Label
    q.format(key)
  in SymbolLiteral
    q.format(key.value)
    q.text(":")
  in DynaSymbol[parts: [TStringContent[value: LABEL] => part]]
    q.format(part)
    q.text(":")
  in DynaSymbol
    q.format(key)
    q.text(":")
  end
end