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
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
10264 10265 10266 10267 10268 10269 |
# File 'lib/syntax_tree/node.rb', line 10264 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
10262 10263 10264 |
# File 'lib/syntax_tree/node.rb', line 10262 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
10259 10260 10261 |
# File 'lib/syntax_tree/node.rb', line 10259 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
10256 10257 10258 |
# File 'lib/syntax_tree/node.rb', line 10256 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
10271 10272 10273 |
# File 'lib/syntax_tree/node.rb', line 10271 def child_nodes [statement, predicate] end |
#deconstruct_keys(keys) ⇒ Object
10277 10278 10279 10280 10281 10282 10283 10284 |
# File 'lib/syntax_tree/node.rb', line 10277 def deconstruct_keys(keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
10286 10287 10288 |
# File 'lib/syntax_tree/node.rb', line 10286 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |
#pretty_print(q) ⇒ Object
10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 |
# File 'lib/syntax_tree/node.rb', line 10290 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
10304 10305 10306 10307 10308 10309 10310 10311 10312 |
# File 'lib/syntax_tree/node.rb', line 10304 def to_json(*opts) { type: :unless_mod, stmt: statement, pred: predicate, loc: location, cmts: comments }.to_json(*opts) end |