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.
12010 12011 12012 12013 12014 12015 |
# File 'lib/syntax_tree.rb', line 12010 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
12008 12009 12010 |
# File 'lib/syntax_tree.rb', line 12008 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
12005 12006 12007 |
# File 'lib/syntax_tree.rb', line 12005 def location @location end |
#parentheses ⇒ Object (readonly)
- boolean
-
whether or not parentheses were used
12002 12003 12004 |
# File 'lib/syntax_tree.rb', line 12002 def parentheses @parentheses end |
#statement ⇒ Object (readonly)
- untyped
-
the statement on which to operate
11999 12000 12001 |
# File 'lib/syntax_tree.rb', line 11999 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object
12017 12018 12019 |
# File 'lib/syntax_tree.rb', line 12017 def child_nodes [statement] end |
#format(q) ⇒ Object
12021 12022 12023 12024 12025 |
# File 'lib/syntax_tree.rb', line 12021 def format(q) q.text(parentheses ? "not(" : "not ") q.format(statement) q.text(")") if parentheses end |
#pretty_print(q) ⇒ Object
12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 |
# File 'lib/syntax_tree.rb', line 12027 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
12038 12039 12040 12041 12042 12043 12044 12045 12046 |
# File 'lib/syntax_tree.rb', line 12038 def to_json(*opts) { type: :not, value: statement, paren: parentheses, loc: location, cmts: comments }.to_json(*opts) end |