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.
4948 4949 4950 4951 |
# File 'lib/syntax_tree/node.rb', line 4948 def initialize(key, value) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
- Label
-
the keyword being used
4943 4944 4945 |
# File 'lib/syntax_tree/node.rb', line 4943 def key @key end |
#value ⇒ Object (readonly)
- untyped
-
the optional value for the keyword
4946 4947 4948 |
# File 'lib/syntax_tree/node.rb', line 4946 def value @value end |
Instance Method Details
#comments ⇒ Object
4953 4954 4955 |
# File 'lib/syntax_tree/node.rb', line 4953 def comments [] end |
#format(q) ⇒ Object
4957 4958 4959 4960 4961 4962 4963 4964 |
# File 'lib/syntax_tree/node.rb', line 4957 def format(q) q.format(key) if value q.text(" ") q.format(value) end end |