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.
2772 2773 2774 2775 2776 2777 2778 |
# File 'lib/syntax_tree/node.rb', line 2772 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
2770 2771 2772 |
# File 'lib/syntax_tree/node.rb', line 2770 def comments @comments end |
#operator ⇒ Object (readonly)
- Kw | Op
-
the operator being used to match against the pattern, which is
either => or in
2764 2765 2766 |
# File 'lib/syntax_tree/node.rb', line 2764 def operator @operator end |
#pattern ⇒ Object (readonly)
- untyped
-
the pattern on the right-hand side of the expression
2767 2768 2769 |
# File 'lib/syntax_tree/node.rb', line 2767 def pattern @pattern end |
#value ⇒ Object (readonly)
- untyped
-
the left-hand expression
2760 2761 2762 |
# File 'lib/syntax_tree/node.rb', line 2760 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
2780 2781 2782 |
# File 'lib/syntax_tree/node.rb', line 2780 def accept(visitor) visitor.visit_rassign(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2784 2785 2786 |
# File 'lib/syntax_tree/node.rb', line 2784 def child_nodes [value, operator, pattern] end |
#deconstruct_keys(_keys) ⇒ Object
2790 2791 2792 2793 2794 2795 2796 2797 2798 |
# File 'lib/syntax_tree/node.rb', line 2790 def deconstruct_keys(_keys) { value: value, operator: operator, pattern: pattern, location: location, comments: comments } end |
#format(q) ⇒ Object
2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 |
# File 'lib/syntax_tree/node.rb', line 2800 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 |