Class: Yadriggy::Break
- Includes:
- AstHelper
- Defined in:
- lib/yadriggy/ast.rb
Overview
break, next, redo, or retry.
Instance Attribute Summary collapse
-
#op ⇒ Symbol
readonly
:break
,:next
,:redo
, or:retry
. -
#values ⇒ Array<ASTnode>
readonly
An array of the break/next arguments.
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
-
#initialize(sexp) ⇒ Break
constructor
A new instance of Break.
Methods included from AstHelper
#has_tag?, #to_node, #to_nodes
Methods inherited from ASTnode
#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class
Constructor Details
#initialize(sexp) ⇒ Break
Returns a new instance of Break.
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 |
# File 'lib/yadriggy/ast.rb', line 1222 def initialize(sexp) @op = sexp[0] if @op == :break || @op == :next if sexp[1].size == 0 @values = [] else values = has_tag?(sexp[1], :args_add_block)[1] @values = to_nodes(values) end add_children(@values) else @values = [] end end |
Instance Attribute Details
#op ⇒ Symbol (readonly)
Returns :break
, :next
, :redo
, or :retry
.
1216 1217 1218 |
# File 'lib/yadriggy/ast.rb', line 1216 def op @op end |
#values ⇒ Array<ASTnode> (readonly)
Returns an array of the break/next arguments.
1218 1219 1220 |
# File 'lib/yadriggy/ast.rb', line 1218 def values @values end |
Class Method Details
.tags ⇒ Object
1220 |
# File 'lib/yadriggy/ast.rb', line 1220 def self.() [:break, :next, :redo, :retry] end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
1240 1241 1242 |
# File 'lib/yadriggy/ast.rb', line 1240 def accept(evaluator) evaluator.break_out(self) end |