Class: SyntaxTree::UnlessMod
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.
-
#predicate ⇒ Object
readonly
[untyped] the expression to be checked.
-
#statement ⇒ Object
readonly
[untyped] the expression to be executed.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(statement:, predicate:, location:, comments: []) ⇒ UnlessMod
constructor
A new instance of UnlessMod.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(statement:, predicate:, location:, comments: []) ⇒ UnlessMod
Returns a new instance of UnlessMod.
9178 9179 9180 9181 9182 9183 |
# File 'lib/syntax_tree/node.rb', line 9178 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
9176 9177 9178 |
# File 'lib/syntax_tree/node.rb', line 9176 def comments @comments end |
#predicate ⇒ Object (readonly)
[untyped] the expression to be checked
9173 9174 9175 |
# File 'lib/syntax_tree/node.rb', line 9173 def predicate @predicate end |
#statement ⇒ Object (readonly)
[untyped] the expression to be executed
9170 9171 9172 |
# File 'lib/syntax_tree/node.rb', line 9170 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
9185 9186 9187 |
# File 'lib/syntax_tree/node.rb', line 9185 def accept(visitor) visitor.visit_unless_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9189 9190 9191 |
# File 'lib/syntax_tree/node.rb', line 9189 def child_nodes [statement, predicate] end |
#deconstruct_keys(_keys) ⇒ Object
9195 9196 9197 9198 9199 9200 9201 9202 |
# File 'lib/syntax_tree/node.rb', line 9195 def deconstruct_keys(_keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
9204 9205 9206 |
# File 'lib/syntax_tree/node.rb', line 9204 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |