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.
12563 12564 12565 12566 12567 12568 |
# File 'lib/syntax_tree.rb', line 12563 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
12561 12562 12563 |
# File 'lib/syntax_tree.rb', line 12561 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
12558 12559 12560 |
# File 'lib/syntax_tree.rb', line 12558 def location @location end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
12555 12556 12557 |
# File 'lib/syntax_tree.rb', line 12555 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
12552 12553 12554 |
# File 'lib/syntax_tree.rb', line 12552 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object
12570 12571 12572 |
# File 'lib/syntax_tree.rb', line 12570 def child_nodes [statement, predicate] end |
#format(q) ⇒ Object
12574 12575 12576 |
# File 'lib/syntax_tree.rb', line 12574 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |
#pretty_print(q) ⇒ Object
12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 |
# File 'lib/syntax_tree.rb', line 12578 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
12592 12593 12594 12595 12596 12597 12598 12599 12600 |
# File 'lib/syntax_tree.rb', line 12592 def to_json(*opts) { type: :unless_mod, stmt: statement, pred: predicate, loc: location, cmts: comments }.to_json(*opts) end |