Class: SyntaxTree::UnlessMod
- Inherits:
-
Object
- Object
- SyntaxTree::UnlessMod
- Defined in:
- lib/syntax_tree.rb
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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#predicate ⇒ Object
readonly
- untyped
-
the expression to be checked.
-
#statement ⇒ Object
readonly
- untyped
-
the expression to be executed.
Instance Method Summary collapse
- #child_nodes ⇒ 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
11847 11848 11849 11850 11851 11852 |
# File 'lib/syntax_tree.rb', line 11847 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
11845 11846 11847 |
# File 'lib/syntax_tree.rb', line 11845 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11842 11843 11844 |
# File 'lib/syntax_tree.rb', line 11842 def location @location end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
11839 11840 11841 |
# File 'lib/syntax_tree.rb', line 11839 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
11836 11837 11838 |
# File 'lib/syntax_tree.rb', line 11836 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object
11854 11855 11856 |
# File 'lib/syntax_tree.rb', line 11854 def child_nodes [statement, predicate] end |
#format(q) ⇒ Object
11858 11859 11860 |
# File 'lib/syntax_tree.rb', line 11858 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |
#pretty_print(q) ⇒ Object
11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 |
# File 'lib/syntax_tree.rb', line 11862 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
11876 11877 11878 11879 11880 11881 11882 11883 11884 |
# File 'lib/syntax_tree.rb', line 11876 def to_json(*opts) { type: :unless_mod, stmt: statement, pred: predicate, loc: location, cmts: comments }.to_json(*opts) end |