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.
4904 4905 4906 4907 |
# File 'lib/syntax_tree/node.rb', line 4904 def initialize(key, value) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
- Label
-
the keyword being used
4899 4900 4901 |
# File 'lib/syntax_tree/node.rb', line 4899 def key @key end |
#value ⇒ Object (readonly)
- untyped
-
the optional value for the keyword
4902 4903 4904 |
# File 'lib/syntax_tree/node.rb', line 4902 def value @value end |
Instance Method Details
#comments ⇒ Object
4909 4910 4911 |
# File 'lib/syntax_tree/node.rb', line 4909 def comments [] end |
#format(q) ⇒ Object
4913 4914 4915 4916 4917 4918 4919 4920 |
# File 'lib/syntax_tree/node.rb', line 4913 def format(q) q.format(key) if value q.text(" ") q.format(value) end end |