Class: SyntaxTree::Not
Overview
Not represents the unary not method being called on an expression.
not value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#parentheses ⇒ Object
readonly
- boolean
-
whether or not parentheses were used.
-
#statement ⇒ Object
readonly
- untyped
-
the statement on which to operate.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(statement:, parentheses:, location:, comments: []) ⇒ Not
constructor
A new instance of Not.
Methods inherited from Node
Constructor Details
#initialize(statement:, parentheses:, location:, comments: []) ⇒ Not
Returns a new instance of Not.
8180 8181 8182 8183 8184 8185 |
# File 'lib/syntax_tree/node.rb', line 8180 def initialize(statement:, parentheses:, location:, comments: []) @statement = statement @parentheses = parentheses @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8178 8179 8180 |
# File 'lib/syntax_tree/node.rb', line 8178 def comments @comments end |
#parentheses ⇒ Object (readonly)
- boolean
-
whether or not parentheses were used
8175 8176 8177 |
# File 'lib/syntax_tree/node.rb', line 8175 def parentheses @parentheses end |
#statement ⇒ Object (readonly)
- untyped
-
the statement on which to operate
8172 8173 8174 |
# File 'lib/syntax_tree/node.rb', line 8172 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
8187 8188 8189 |
# File 'lib/syntax_tree/node.rb', line 8187 def accept(visitor) visitor.visit_not(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8191 8192 8193 |
# File 'lib/syntax_tree/node.rb', line 8191 def child_nodes [statement] end |
#deconstruct_keys(keys) ⇒ Object
8197 8198 8199 8200 8201 8202 8203 8204 |
# File 'lib/syntax_tree/node.rb', line 8197 def deconstruct_keys(keys) { statement: statement, parentheses: parentheses, location: location, comments: comments } end |
#format(q) ⇒ Object
8206 8207 8208 8209 8210 |
# File 'lib/syntax_tree/node.rb', line 8206 def format(q) q.text(parentheses ? "not(" : "not ") q.format(statement) q.text(")") if parentheses end |