Class: Red::ControlNode::Rescue
- Inherits:
-
Red::ControlNode
- Object
- String
- Red::ControlNode
- Red::ControlNode::Rescue
- Defined in:
- lib/red/nodes/control_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(attempted_sexp, rescue_body_sexp, options = {}) ⇒ Rescue
constructor
[:rescue, (expression | :block), :resbody].
Methods inherited from String
#%, #*, #+, #<<, #<=>, #==, #=~, #[], #[]=, #capitalize, #capitalize!, #casecmp, #center, #chomp, #chomp!, #chop, #chop!, #concat, #count, #crypt, #delete, #delete!, #downcase, #downcase!, #each, #each_byte, #each_line, #empty?, #eql?, #gsub, #gsub!, #hash, #hex, #include?, #index, #insert, #inspect, #intern, #length, #ljust, #lstrip, #lstrip!, #match, #next, #next!, #oct, #replace, #reverse, #reverse!, #rindex, #rjust, #rstrip, #rstrip!, #scan, #size, #slice, #slice!, #split, #squeeze, #strip, #strip!, #strip_scripts, #sub, #sub!, #succ, #succ!, #sum, #swapcase, #swapcase!, #to_f, #to_i, #to_s, #to_str, #to_sym, #tr, #tr!, #tr_s, #tr_s!, #upcase, #upcase!, #upto
Constructor Details
#initialize(attempted_sexp, rescue_body_sexp, options = {}) ⇒ Rescue
- :rescue, (expression | :block), :resbody
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/red/nodes/control_nodes.rb', line 26 def initialize(attempted_sexp, rescue_body_sexp, = {}) ( = rescue_body_sexp) && (rescue_body_sexp = attempted_sexp) && (attempted_sexp = [:nil]) if rescue_body_sexp.is_a?(Hash) string = "try{%s;}catch(_e){_eRescued=false;%s;if(!_eRescued){throw(_e);};}" if [:as_argument] || [:as_assignment] string = "function(){%s;}.m$(this)()" % string [:force_return] = true end attempted = (attempted_sexp.is_sexp?(:block) ? attempted_sexp : [:block, attempted_sexp]).red!(:force_return => [:force_return]) rescue_body = rescue_body_sexp.red!(:force_return => [:force_return]) self << "try{%s;}catch(_e){_eRescued=false;%s;if(!_eRescued){throw(_e);};}" % [attempted, rescue_body] end |