Class: SyntaxTree::IfMod
Overview
IfMod represents the modifier form of an if statement.
expression if 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: []) ⇒ IfMod
constructor
A new instance of IfMod.
Methods inherited from Node
Constructor Details
#initialize(statement:, predicate:, location:, comments: []) ⇒ IfMod
Returns a new instance of IfMod.
4892 4893 4894 4895 4896 4897 |
# File 'lib/syntax_tree/node.rb', line 4892 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
4890 4891 4892 |
# File 'lib/syntax_tree/node.rb', line 4890 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
4887 4888 4889 |
# File 'lib/syntax_tree/node.rb', line 4887 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
4884 4885 4886 |
# File 'lib/syntax_tree/node.rb', line 4884 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
4899 4900 4901 |
# File 'lib/syntax_tree/node.rb', line 4899 def accept(visitor) visitor.visit_if_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4903 4904 4905 |
# File 'lib/syntax_tree/node.rb', line 4903 def child_nodes [statement, predicate] end |
#deconstruct_keys(keys) ⇒ Object
4909 4910 4911 4912 4913 4914 4915 4916 |
# File 'lib/syntax_tree/node.rb', line 4909 def deconstruct_keys(keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
4918 4919 4920 |
# File 'lib/syntax_tree/node.rb', line 4918 def format(q) ConditionalModFormatter.new("if", self).format(q) end |