Class: SyntaxTree::HshPtn::KeywordFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::HshPtn::KeywordFormatter
- Defined in:
- lib/syntax_tree/node.rb
Overview
Formats a key-value pair in a hash pattern. The value is optional.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
- Label
-
the keyword being used.
-
#value ⇒ Object
readonly
- untyped
-
the optional value for the keyword.
Instance Method Summary collapse
- #comments ⇒ Object
- #format(q) ⇒ Object
-
#initialize(key, value) ⇒ KeywordFormatter
constructor
A new instance of KeywordFormatter.
Constructor Details
#initialize(key, value) ⇒ KeywordFormatter
Returns a new instance of KeywordFormatter.
4987 4988 4989 4990 |
# File 'lib/syntax_tree/node.rb', line 4987 def initialize(key, value) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
- Label
-
the keyword being used
4982 4983 4984 |
# File 'lib/syntax_tree/node.rb', line 4982 def key @key end |
#value ⇒ Object (readonly)
- untyped
-
the optional value for the keyword
4985 4986 4987 |
# File 'lib/syntax_tree/node.rb', line 4985 def value @value end |
Instance Method Details
#comments ⇒ Object
4992 4993 4994 |
# File 'lib/syntax_tree/node.rb', line 4992 def comments [] end |
#format(q) ⇒ Object
4996 4997 4998 4999 5000 5001 5002 5003 |
# File 'lib/syntax_tree/node.rb', line 4996 def format(q) q.format(key) if value q.text(" ") q.format(value) end end |