Skip to content
Browse files

Add explanation for double colon

  • Loading branch information...
1 parent 4b83eb8 commit 1e66b23e48e32b40fdce294160a5b5fc13b9b56c @radar radar committed Sep 20, 2010
Showing with 15 additions and 0 deletions.
  1. +11 −0 explanations/colon2.md
  2. +1 −0 fixtures/colon2.rb
  3. +3 −0 processor.rb
View
11 explanations/colon2.md
@@ -0,0 +1,11 @@
+## :: separator
+
+A `::` separator is used to indicate that the right-hand-side constant is defined within the scope of the left-hand-side constant. Take this for example:
+
+ module Foo
+ class Bar
+
+ end
+ end
+
+To get to the `Bar` class we would use `::` like this: `Foo::Bar`.
View
1 fixtures/colon2.rb
@@ -0,0 +1 @@
+Foo::Bar.baz
View
3 processor.rb
@@ -119,10 +119,13 @@ def process_if(exp)
end
CALLS = [:require, :attr_accessor, :attr_reader, :attr_writer, :include, :extend]
+ SPECIALS = [:colon2]
def process_call(exp)
if exp[0].nil? and CALLS.include? exp[1]
mark(exp[1]) + super
+ elsif !exp[0].nil? and SPECIALS.include? exp[0][0]
+ mark(exp[0][0]) + super
else
super
end

0 comments on commit 1e66b23

Please sign in to comment.
Something went wrong with that request. Please try again.