Class: Brandish::Parser::Node::Pair
- Inherits:
-
Brandish::Parser::Node
- Object
- Brandish::Parser::Node
- Brandish::Parser::Node::Pair
- Defined in:
- lib/brandish/parser/node/pair.rb
Overview
A key-value pair used for a command. This is used to represent an argument for the command node.
Instance Attribute Summary collapse
-
#key ⇒ Scanner::Token
readonly
The key of the pair.
-
#value ⇒ Parser::Node::Text, Parser::Node::String
readonly
The value of the pair.
Attributes inherited from Brandish::Parser::Node
Instance Method Summary collapse
-
#initialize(key:, value:, location: nil) ⇒ Pair
constructor
Initialize the pair node with the given key, value and location.
-
#inspect ⇒ ::String
Pretty inspect.
Methods inherited from Brandish::Parser::Node
#prevent_update, #update, #update_prevented?
Constructor Details
#initialize(key:, value:, location: nil) ⇒ Pair
Initialize the pair node with the given key, value and location.
25 26 27 28 29 30 |
# File 'lib/brandish/parser/node/pair.rb', line 25 def initialize(key:, value:, location: nil) @key = key @value = value @location = location || key.location.union(value.location) freeze end |
Instance Attribute Details
#key ⇒ Scanner::Token (readonly)
The key of the pair. This will always be a :TEXT
.
13 14 15 |
# File 'lib/brandish/parser/node/pair.rb', line 13 def key @key end |
#value ⇒ Parser::Node::Text, Parser::Node::String (readonly)
The value of the pair.
18 19 20 |
# File 'lib/brandish/parser/node/pair.rb', line 18 def value @value end |
Instance Method Details
#inspect ⇒ ::String
Pretty inspect.
35 36 37 38 |
# File 'lib/brandish/parser/node/pair.rb', line 35 def inspect "#<#{self.class} key=#{@key.inspect} value=#{@value.inspect} " \ "location=#{@location.inspect}>" end |