lib/facet/symbol/to_const.rb in facets-0.9.0 vs lib/facet/symbol/to_const.rb in facets-1.0.0

- old
+ new

@@ -1,39 +1,78 @@ -require 'nano/symbol/to_const.rb' \ No newline at end of file +require 'facet/string/to_const' + +class Symbol + + # Get a constant by a given symbol name. + # + # :Class.to_const #=> Class + # + # Note this method is not as verstile as it should be, + # since it can not access contants relative to the current + # execution context. But without a binding_of_caller that + # does not seem possible. + def to_const + to_s.to_const + end + +end + + +# _____ _ +# |_ _|__ ___| |_ +# | |/ _ \/ __| __| +# | | __/\__ \ |_ +# |_|\___||___/\__| +# +=begin test + + require 'test/unit' + + class TCSymbol < Test::Unit::TestCase + + TESTCONST = 1 + + def test_to_const + assert_equal( 1, :"TCSymbol::TESTCONST".to_const ) + end + + end + +=end