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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#parentheses ⇒ Object
readonly
- boolean
-
whether or not parentheses were used.
-
#statement ⇒ Object
readonly
- untyped
-
the statement on which to operate.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(statement:, parentheses:, location:, comments: []) ⇒ Not
constructor
A new instance of Not.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(statement:, parentheses:, location:, comments: []) ⇒ Not
Returns a new instance of Not.
10380 10381 10382 10383 10384 10385 |
# File 'lib/syntax_tree/node.rb', line 10380 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
10378 10379 10380 |
# File 'lib/syntax_tree/node.rb', line 10378 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10375 10376 10377 |
# File 'lib/syntax_tree/node.rb', line 10375 def location @location end |
#parentheses ⇒ Object (readonly)
- boolean
-
whether or not parentheses were used
10372 10373 10374 |
# File 'lib/syntax_tree/node.rb', line 10372 def parentheses @parentheses end |
#statement ⇒ Object (readonly)
- untyped
-
the statement on which to operate
10369 10370 10371 |
# File 'lib/syntax_tree/node.rb', line 10369 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
10387 10388 10389 |
# File 'lib/syntax_tree/node.rb', line 10387 def child_nodes [statement] end |
#deconstruct_keys(keys) ⇒ Object
10393 10394 10395 10396 10397 10398 10399 10400 |
# File 'lib/syntax_tree/node.rb', line 10393 def deconstruct_keys(keys) { statement: statement, parentheses: parentheses, location: location, comments: comments } end |
#format(q) ⇒ Object
10402 10403 10404 10405 10406 |
# File 'lib/syntax_tree/node.rb', line 10402 def format(q) q.text(parentheses ? "not(" : "not ") q.format(statement) q.text(")") if parentheses end |
#pretty_print(q) ⇒ Object
10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 |
# File 'lib/syntax_tree/node.rb', line 10408 def pretty_print(q) q.group(2, "(", ")") do q.text("not") q.breakable q.pp(statement) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
10419 10420 10421 10422 10423 10424 10425 10426 10427 |
# File 'lib/syntax_tree/node.rb', line 10419 def to_json(*opts) { type: :not, value: statement, paren: parentheses, loc: location, cmts: comments }.to_json(*opts) end |