Class: SyntaxTree::CallOperatorFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::CallOperatorFormatter
- Defined in:
- lib/syntax_tree.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.
3143 3144 3145 |
# File 'lib/syntax_tree.rb', line 3143 def initialize(operator) @operator = operator end |
Instance Attribute Details
#operator ⇒ Object (readonly)
- :“::” | Op | Period
-
the operator being formatted
3141 3142 3143 |
# File 'lib/syntax_tree.rb', line 3141 def operator @operator end |
Instance Method Details
#comments ⇒ Object
3147 3148 3149 |
# File 'lib/syntax_tree.rb', line 3147 def comments operator == :"::" ? [] : operator.comments end |
#format(q) ⇒ Object
3151 3152 3153 3154 3155 3156 3157 |
# File 'lib/syntax_tree.rb', line 3151 def format(q) if operator == :"::" || (operator.is_a?(Op) && operator.value == "::") q.text(".") else operator.format(q) end end |