Class: SyntaxTree::Not
- Inherits:
-
Object
- Object
- SyntaxTree::Not
- Defined in:
- lib/syntax_tree.rb
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
- #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.
11506 11507 11508 11509 11510 11511 |
# File 'lib/syntax_tree.rb', line 11506 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
11504 11505 11506 |
# File 'lib/syntax_tree.rb', line 11504 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11501 11502 11503 |
# File 'lib/syntax_tree.rb', line 11501 def location @location end |
#parentheses ⇒ Object (readonly)
- boolean
-
whether or not parentheses were used
11498 11499 11500 |
# File 'lib/syntax_tree.rb', line 11498 def parentheses @parentheses end |
#statement ⇒ Object (readonly)
- untyped
-
the statement on which to operate
11495 11496 11497 |
# File 'lib/syntax_tree.rb', line 11495 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object
11513 11514 11515 |
# File 'lib/syntax_tree.rb', line 11513 def child_nodes [statement] end |
#format(q) ⇒ Object
11517 11518 11519 11520 11521 |
# File 'lib/syntax_tree.rb', line 11517 def format(q) q.text(parentheses ? "not(" : "not ") q.format(statement) q.text(")") if parentheses end |
#pretty_print(q) ⇒ Object
11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 |
# File 'lib/syntax_tree.rb', line 11523 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
11534 11535 11536 11537 11538 11539 11540 11541 11542 |
# File 'lib/syntax_tree.rb', line 11534 def to_json(*opts) { type: :not, value: statement, paren: parentheses, loc: location, cmts: comments }.to_json(*opts) end |