Class: SyntaxTree::RAssign
Overview
RAssign represents a single-line pattern match.
value in pattern
value => pattern
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#operator ⇒ Object
readonly
- Kw | Op
-
the operator being used to match against the pattern, which is either => or in.
-
#pattern ⇒ Object
readonly
- untyped
-
the pattern on the right-hand side of the expression.
-
#value ⇒ Object
readonly
- untyped
-
the left-hand expression.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, operator:, pattern:, location:, comments: []) ⇒ RAssign
constructor
A new instance of RAssign.
Methods inherited from Node
Constructor Details
#initialize(value:, operator:, pattern:, location:, comments: []) ⇒ RAssign
Returns a new instance of RAssign.
2324 2325 2326 2327 2328 2329 2330 |
# File 'lib/syntax_tree/node.rb', line 2324 def initialize(value:, operator:, pattern:, location:, comments: []) @value = value @operator = operator @pattern = pattern @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2322 2323 2324 |
# File 'lib/syntax_tree/node.rb', line 2322 def comments @comments end |
#operator ⇒ Object (readonly)
- Kw | Op
-
the operator being used to match against the pattern, which is
either => or in
2316 2317 2318 |
# File 'lib/syntax_tree/node.rb', line 2316 def operator @operator end |
#pattern ⇒ Object (readonly)
- untyped
-
the pattern on the right-hand side of the expression
2319 2320 2321 |
# File 'lib/syntax_tree/node.rb', line 2319 def pattern @pattern end |
#value ⇒ Object (readonly)
- untyped
-
the left-hand expression
2312 2313 2314 |
# File 'lib/syntax_tree/node.rb', line 2312 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
2332 2333 2334 |
# File 'lib/syntax_tree/node.rb', line 2332 def accept(visitor) visitor.visit_rassign(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2336 2337 2338 |
# File 'lib/syntax_tree/node.rb', line 2336 def child_nodes [value, operator, pattern] end |
#deconstruct_keys(keys) ⇒ Object
2342 2343 2344 2345 2346 2347 2348 2349 2350 |
# File 'lib/syntax_tree/node.rb', line 2342 def deconstruct_keys(keys) { value: value, operator: operator, pattern: pattern, location: location, comments: comments } end |
#format(q) ⇒ Object
2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 |
# File 'lib/syntax_tree/node.rb', line 2352 def format(q) q.group do q.format(value) q.text(" ") q.format(operator) q.group do q.indent do q.breakable q.format(pattern) end end end end |