Class: Red::VariableNode::Constant
- Inherits:
-
Red::VariableNode
- Object
- String
- Red::VariableNode
- Red::VariableNode::Constant
- Defined in:
- lib/red/nodes/variable_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(constant_name_sexp, options) ⇒ Constant
constructor
[:const, :Foo].
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(constant_name_sexp, options) ⇒ Constant
- :const, :Foo
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/red/nodes/variable_nodes.rb', line 29 def initialize(constant_name_sexp, ) constant_name = "c$%s" % constant_name_sexp.red! locally_namespaced_constant = (@@namespace_stack + [constant_name]).join('.') i = -1 begin constant = (@@namespace_stack[0..i] + [constant_name]).join('.') preexisting_constant_namespace = constant if @@red_constants.include?(constant) i -= 1 end until preexisting_constant_namespace || @@namespace_stack.size + i < -1 self << "%s" % [(preexisting_constant_namespace || locally_namespaced_constant)] end |