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.
5904 5905 5906 5907 |
# File 'lib/syntax_tree/node.rb', line 5904 def initialize(key, value) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
- Label
-
the keyword being used
5899 5900 5901 |
# File 'lib/syntax_tree/node.rb', line 5899 def key @key end |
#value ⇒ Object (readonly)
- untyped
-
the optional value for the keyword
5902 5903 5904 |
# File 'lib/syntax_tree/node.rb', line 5902 def value @value end |
Instance Method Details
#comments ⇒ Object
5909 5910 5911 |
# File 'lib/syntax_tree/node.rb', line 5909 def comments [] end |
#format(q) ⇒ Object
5913 5914 5915 5916 5917 5918 5919 5920 |
# File 'lib/syntax_tree/node.rb', line 5913 def format(q) q.format(key) if value q.text(" ") q.format(value) end end |