Class: SyntaxTree::HashKeyFormatter::Labels
- Inherits:
-
Object
- Object
- SyntaxTree::HashKeyFormatter::Labels
- 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
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 |
# File 'lib/syntax_tree/node.rb', line 1405 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 |