Class: SyntaxTree::CallOperatorFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::CallOperatorFormatter
- Defined in:
- lib/syntax_tree/node.rb
Overview
- Wraps a call operator (which can be a string literal
-
or an Op node or a
Period node) and formats it when called.
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
- :“::” | Op | Period
-
the operator being formatted.
Instance Method Summary collapse
- #comments ⇒ Object
- #format(q) ⇒ Object
-
#initialize(operator) ⇒ CallOperatorFormatter
constructor
A new instance of CallOperatorFormatter.
Constructor Details
#initialize(operator) ⇒ CallOperatorFormatter
Returns a new instance of CallOperatorFormatter.
2614 2615 2616 |
# File 'lib/syntax_tree/node.rb', line 2614 def initialize(operator) @operator = operator end |
Instance Attribute Details
#operator ⇒ Object (readonly)
- :“::” | Op | Period
-
the operator being formatted
2612 2613 2614 |
# File 'lib/syntax_tree/node.rb', line 2612 def operator @operator end |
Instance Method Details
#comments ⇒ Object
2618 2619 2620 |
# File 'lib/syntax_tree/node.rb', line 2618 def comments operator == :"::" ? [] : operator.comments end |
#format(q) ⇒ Object
2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 |
# File 'lib/syntax_tree/node.rb', line 2622 def format(q) case operator when :"::" q.text(".") when Op operator.value == "::" ? q.text(".") : operator.format(q) else operator.format(q) end end |