Sha256: 021928aeb79fe20cbdba979049301fd61fbdb79094e2a8ccc936caf6d4c3f3c5
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
#----------------------------------------------------- # support define and bind variable dynamically #----------------------------------------------------- $dyn_vars = nil # set value to a variable def set_var(var_name, var_value) if $dyn_vars == nil $dyn_vars = binding end strEval = var_name + "=" + var_value eval strEval, $dyn_vars end # bind string with $dyn_vars context def bind_with_dyn_vars(str) if $dyn_vars == nil $dyn_vars = binding end strEval = '"' + str + '"' return eval strEval, $dyn_vars end # evaluate operation/statement with $dyn_vars context def eval_with_dyn_vars(operation) if $dyn_vars == nil $dyn_vars = binding end eval operation, $dyn_vars end def bind_with_dyn_json_vars(json, bind_json) if json.kind_of? Hash json.each_pair do |k, v| if v.kind_of? String bind_json[bind_with_dyn_vars(k)] = bind_with_dyn_json_vars(v, bind_json) elsif v.kind_of? Hash temp = Hash.new v.each_pair do |k1, v1| temp[bind_with_dyn_vars(k1)] = bind_with_dyn_json_vars(v1, temp) end bind_json[bind_with_dyn_vars(k)] = temp elsif v.kind_of? Array temp1 = Array.new v.each {|item| temp2 = Hash.new bind_with_dyn_json_vars(item, temp2) temp1 << temp2 } bind_json[bind_with_dyn_vars(k)] = temp1 end end elsif json.kind_of? Array temp1 = Array.new json.each {|item| temp2 = Hash.new bind_with_dyn_json_vars(item, temp2) temp1 << temp2 } return temp1 else return bind_with_dyn_vars(json) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Ifd_Mobile-1.5.0 | lib/Ifd_Mobile/methods/auto_utils.rb |