Class: SyntaxTree::Unless
Overview
Unless represents the first clause in an unless chain.
unless predicate
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#consequent ⇒ Object
readonly
- nil, Elsif, Else
-
the next clause in the chain.
-
#predicate ⇒ Object
readonly
- untyped
-
the expression to be checked.
-
#statements ⇒ Object
readonly
- Statements
-
the expressions 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(predicate:, statements:, consequent:, location:, comments: []) ⇒ Unless
constructor
A new instance of Unless.
Methods inherited from Node
Constructor Details
#initialize(predicate:, statements:, consequent:, location:, comments: []) ⇒ Unless
Returns a new instance of Unless.
8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 |
# File 'lib/syntax_tree/node.rb', line 8904 def initialize( predicate:, statements:, consequent:, location:, comments: [] ) @predicate = predicate @statements = statements @consequent = consequent @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8902 8903 8904 |
# File 'lib/syntax_tree/node.rb', line 8902 def comments @comments end |
#consequent ⇒ Object (readonly)
- nil, Elsif, Else
-
the next clause in the chain
8899 8900 8901 |
# File 'lib/syntax_tree/node.rb', line 8899 def consequent @consequent end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
8893 8894 8895 |
# File 'lib/syntax_tree/node.rb', line 8893 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
8896 8897 8898 |
# File 'lib/syntax_tree/node.rb', line 8896 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
8918 8919 8920 |
# File 'lib/syntax_tree/node.rb', line 8918 def accept(visitor) visitor.visit_unless(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8922 8923 8924 |
# File 'lib/syntax_tree/node.rb', line 8922 def child_nodes [predicate, statements, consequent] end |
#deconstruct_keys(keys) ⇒ Object
8928 8929 8930 8931 8932 8933 8934 8935 8936 |
# File 'lib/syntax_tree/node.rb', line 8928 def deconstruct_keys(keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end |
#format(q) ⇒ Object
8938 8939 8940 |
# File 'lib/syntax_tree/node.rb', line 8938 def format(q) ConditionalFormatter.new("unless", self).format(q) end |