Class: Red::AssignmentNode::LocalVariable
- Inherits:
-
Red::AssignmentNode
- Object
- String
- Red::AssignmentNode
- Red::AssignmentNode::LocalVariable
- Defined in:
- lib/red/nodes/assignment_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(variable_name_sexp, expression_sexp, options) ⇒ LocalVariable
constructor
- :lasgn, :foo, expression
- :dasgn, :foo, expression
-
> previously defined inside a proc, but not the nearest proc [:dasgn_curr, :foo, expression] => local to the nearest proc.
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(variable_name_sexp, expression_sexp, options) ⇒ LocalVariable
- :lasgn, :foo, expression
- :dasgn, :foo, expression
-
> previously defined inside a proc, but not the nearest proc
- :dasgn_curr, :foo, expression
-
> local to the nearest proc
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/red/nodes/assignment_nodes.rb', line 46 def initialize(variable_name_sexp, expression_sexp, ) variable_name = variable_name_sexp.red! expression = expression_sexp.red!(:as_assignment => true) a = javascript_safe_succ!(@@red_boolean).dup if [:as_argument_default] self << "%s=$T($.%s=%s)?$.%s:%s" % [variable_name, a, variable_name, a, expression] else self << "%s=%s" % [variable_name, expression] end end |