Class: Peruby::Op::BareBlock
Overview
A standalone Perl block behaves as a one-iteration loop.
Instance Method Summary collapse
-
#initialize(body, label) ⇒ BareBlock
constructor
A new instance of BareBlock.
- #run(env, context) ⇒ Object
Methods inherited from Base
#argument_cells, #local_slot, #lvalue, #run_subroutine, #to_callable, #warning_directive?
Constructor Details
#initialize(body, label) ⇒ BareBlock
Returns a new instance of BareBlock.
153 154 155 156 |
# File 'lib/peruby/op/control.rb', line 153 def initialize(body, label) @body = body @label = label end |
Instance Method Details
#run(env, context) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/peruby/op/control.rb', line 158 def run(env, context) loop do return @body.run(env, context) rescue LoopControl => e raise unless e.label.nil? || e.label == @label return nil unless e.kind == :redo end end |