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.
4986 4987 4988 4989 |
# File 'lib/syntax_tree/node.rb', line 4986 def initialize(key, value) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
- Label
-
the keyword being used
4981 4982 4983 |
# File 'lib/syntax_tree/node.rb', line 4981 def key @key end |
#value ⇒ Object (readonly)
- untyped
-
the optional value for the keyword
4984 4985 4986 |
# File 'lib/syntax_tree/node.rb', line 4984 def value @value end |
Instance Method Details
#comments ⇒ Object
4991 4992 4993 |
# File 'lib/syntax_tree/node.rb', line 4991 def comments [] end |
#format(q) ⇒ Object
4995 4996 4997 4998 4999 5000 5001 5002 |
# File 'lib/syntax_tree/node.rb', line 4995 def format(q) q.format(key) if value q.text(" ") q.format(value) end end |