Class: SyntaxTree::UnlessMod
- Inherits:
-
Object
- Object
- SyntaxTree::UnlessMod
- Defined in:
- lib/syntax_tree.rb
Overview
UnlessMod represents the modifier form of an unless statement.
expression unless predicate
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.
-
#predicate ⇒ Object
readonly
- untyped
-
the expression to be checked.
-
#statement ⇒ Object
readonly
- untyped
-
the expression to be executed.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(statement:, predicate:, location:, comments: []) ⇒ UnlessMod
constructor
A new instance of UnlessMod.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(statement:, predicate:, location:, comments: []) ⇒ UnlessMod
Returns a new instance of UnlessMod.
12351 12352 12353 12354 12355 12356 |
# File 'lib/syntax_tree.rb', line 12351 def initialize(statement:, predicate:, location:, comments: []) @statement = statement @predicate = predicate @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
12349 12350 12351 |
# File 'lib/syntax_tree.rb', line 12349 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
12346 12347 12348 |
# File 'lib/syntax_tree.rb', line 12346 def location @location end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
12343 12344 12345 |
# File 'lib/syntax_tree.rb', line 12343 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
12340 12341 12342 |
# File 'lib/syntax_tree.rb', line 12340 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object
12358 12359 12360 |
# File 'lib/syntax_tree.rb', line 12358 def child_nodes [statement, predicate] end |
#format(q) ⇒ Object
12362 12363 12364 |
# File 'lib/syntax_tree.rb', line 12362 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |
#pretty_print(q) ⇒ Object
12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 |
# File 'lib/syntax_tree.rb', line 12366 def pretty_print(q) q.group(2, "(", ")") do q.text("unless_mod") q.breakable q.pp(statement) q.breakable q.pp(predicate) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
12380 12381 12382 12383 12384 12385 12386 12387 12388 |
# File 'lib/syntax_tree.rb', line 12380 def to_json(*opts) { type: :unless_mod, stmt: statement, pred: predicate, loc: location, cmts: comments }.to_json(*opts) end |