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.
8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 |
# File 'lib/syntax_tree/node.rb', line 8903 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
8901 8902 8903 |
# File 'lib/syntax_tree/node.rb', line 8901 def comments @comments end |
#consequent ⇒ Object (readonly)
- nil, Elsif, Else
-
the next clause in the chain
8898 8899 8900 |
# File 'lib/syntax_tree/node.rb', line 8898 def consequent @consequent end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
8892 8893 8894 |
# File 'lib/syntax_tree/node.rb', line 8892 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
8895 8896 8897 |
# File 'lib/syntax_tree/node.rb', line 8895 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
8917 8918 8919 |
# File 'lib/syntax_tree/node.rb', line 8917 def accept(visitor) visitor.visit_unless(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8921 8922 8923 |
# File 'lib/syntax_tree/node.rb', line 8921 def child_nodes [predicate, statements, consequent] end |
#deconstruct_keys(keys) ⇒ Object
8927 8928 8929 8930 8931 8932 8933 8934 8935 |
# File 'lib/syntax_tree/node.rb', line 8927 def deconstruct_keys(keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end |
#format(q) ⇒ Object
8937 8938 8939 |
# File 'lib/syntax_tree/node.rb', line 8937 def format(q) ConditionalFormatter.new("unless", self).format(q) end |