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
- Node
-
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.
6018 6019 6020 6021 |
# File 'lib/syntax_tree/node.rb', line 6018 def initialize(key, value) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
- Label
-
the keyword being used
6013 6014 6015 |
# File 'lib/syntax_tree/node.rb', line 6013 def key @key end |
#value ⇒ Object (readonly)
- Node
-
the optional value for the keyword
6016 6017 6018 |
# File 'lib/syntax_tree/node.rb', line 6016 def value @value end |
Instance Method Details
#comments ⇒ Object
6023 6024 6025 |
# File 'lib/syntax_tree/node.rb', line 6023 def comments [] end |
#format(q) ⇒ Object
6027 6028 6029 6030 6031 6032 6033 6034 |
# File 'lib/syntax_tree/node.rb', line 6027 def format(q) HashKeyFormatter::Labels.new.format_key(q, key) if value q.text(" ") q.format(value) end end |