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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, operator:, pattern:, location:, comments: []) ⇒ RAssign
Returns a new instance of RAssign.
2725 2726 2727 2728 2729 2730 2731 |
# File 'lib/syntax_tree/node.rb', line 2725 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
2723 2724 2725 |
# File 'lib/syntax_tree/node.rb', line 2723 def comments @comments end |
#operator ⇒ Object (readonly)
- Kw | Op
-
the operator being used to match against the pattern, which is
either => or in
2717 2718 2719 |
# File 'lib/syntax_tree/node.rb', line 2717 def operator @operator end |
#pattern ⇒ Object (readonly)
- untyped
-
the pattern on the right-hand side of the expression
2720 2721 2722 |
# File 'lib/syntax_tree/node.rb', line 2720 def pattern @pattern end |
#value ⇒ Object (readonly)
- untyped
-
the left-hand expression
2713 2714 2715 |
# File 'lib/syntax_tree/node.rb', line 2713 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
2733 2734 2735 |
# File 'lib/syntax_tree/node.rb', line 2733 def accept(visitor) visitor.visit_rassign(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2737 2738 2739 |
# File 'lib/syntax_tree/node.rb', line 2737 def child_nodes [value, operator, pattern] end |
#deconstruct_keys(_keys) ⇒ Object
2743 2744 2745 2746 2747 2748 2749 2750 2751 |
# File 'lib/syntax_tree/node.rb', line 2743 def deconstruct_keys(_keys) { value: value, operator: operator, pattern: pattern, location: location, comments: comments } end |
#format(q) ⇒ Object
2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 |
# File 'lib/syntax_tree/node.rb', line 2753 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 |