Class: SyntaxTree::UntilMod
- Inherits:
-
Object
- Object
- SyntaxTree::UntilMod
- Defined in:
- lib/syntax_tree.rb
Overview
UntilMod represents the modifier form of a until loop.
expression until 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: []) ⇒ UntilMod
constructor
A new instance of UntilMod.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(statement:, predicate:, location:, comments: []) ⇒ UntilMod
Returns a new instance of UntilMod.
12046 12047 12048 12049 12050 12051 |
# File 'lib/syntax_tree.rb', line 12046 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
12044 12045 12046 |
# File 'lib/syntax_tree.rb', line 12044 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
12041 12042 12043 |
# File 'lib/syntax_tree.rb', line 12041 def location @location end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
12038 12039 12040 |
# File 'lib/syntax_tree.rb', line 12038 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
12035 12036 12037 |
# File 'lib/syntax_tree.rb', line 12035 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object
12053 12054 12055 |
# File 'lib/syntax_tree.rb', line 12053 def child_nodes [statement, predicate] end |
#format(q) ⇒ Object
12057 12058 12059 |
# File 'lib/syntax_tree.rb', line 12057 def format(q) LoopFormatter.new("until", self, statement).format(q) end |
#pretty_print(q) ⇒ Object
12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 |
# File 'lib/syntax_tree.rb', line 12061 def pretty_print(q) q.group(2, "(", ")") do q.text("until_mod") q.breakable q.pp(statement) q.breakable q.pp(predicate) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
12075 12076 12077 12078 12079 12080 12081 12082 12083 |
# File 'lib/syntax_tree.rb', line 12075 def to_json(*opts) { type: :until_mod, stmt: statement, pred: predicate, loc: location, cmts: comments }.to_json(*opts) end |