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
5147 5148 5149 5150 |
# File 'lib/syntax_tree/node.rb', line 5147 def initialize(key, value) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
- Label
-
the keyword being used
5142 5143 5144 |
# File 'lib/syntax_tree/node.rb', line 5142 def key @key end |
#value ⇒ Object (readonly)
- untyped
-
the optional value for the keyword
5145 5146 5147 |
# File 'lib/syntax_tree/node.rb', line 5145 def value @value end |
Instance Method Details
#comments ⇒ Object
5152 5153 5154 |
# File 'lib/syntax_tree/node.rb', line 5152 def comments [] end |
#format(q) ⇒ Object
5156 5157 5158 5159 5160 5161 5162 5163 |
# File 'lib/syntax_tree/node.rb', line 5156 def format(q) q.format(key) if value q.text(" ") q.format(value) end end |