Created
September 6, 2012 22:09
-
-
Save tsnow/3660747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.9.3p253 :001 > require 'ripper' | |
=> true | |
1.9.3p253 :002 > class A | |
1.9.3p253 :003?> class B | |
1.9.3p253 :004?> end | |
1.9.3p253 :005?> def self.Fart | |
1.9.3p253 :006?> end | |
1.9.3p253 :007?> end | |
=> nil | |
1.9.3p253 :008 > Ripper.sexp('A.B') | |
=> [:program, [[:call, [:var_ref, [:@const, "A", [1, 0]]], :".", [:@const, "B", [1, 2]]]]] | |
1.9.3p253 :009 > Ripper.sexp('A::B') | |
=> [:program, [[:const_path_ref, [:var_ref, [:@const, "A", [1, 0]]], [:@const, "B", [1, 3]]]]] | |
1.9.3p253 :010 > Ripper.sexp('A::Fart') | |
=> [:program, [[:const_path_ref, [:var_ref, [:@const, "A", [1, 0]]], [:@const, "Fart", [1, 3]]]]] | |
1.9.3p253 :011 > Ripper.sexp('A::bart') | |
=> [:program, [[:call, [:var_ref, [:@const, "A", [1, 0]]], :"::", [:@ident, "bart", [1, 3]]]]] | |
1.9.3p253 :012 > A::Fart | |
NameError: uninitialized constant A::Fart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment