SixArm.com » Ruby » String#to_class method to convert a String to a Class
CSS JavaScript HTML Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.yardoc
coverage
doc
lib
test
.codeclimate.yml
.document
.gemtest
.rspec
.travis.yml
CHANGES.md
LICENSE.md
README.md
Rakefile
VERSION
sixarm_ruby_string_to_class-1.1.0-sha512.txt
sixarm_ruby_string_to_class-1.1.0.gem
sixarm_ruby_string_to_class-1.1.1.gem
sixarm_ruby_string_to_class.gemspec

README.md

Ruby »
String#to_class method to convert a string to a class.

Introduction

Ruby String#to_class method to convert from a String to a class

Example:

"Foo".to_class  #=> Foo class

From Mirage at http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/

Install

To install using a Gemfile, add this:

gem "sixarm_ruby_string_to_class", ">= 1.1.1", "< 2"

To install using the command line, run this:

gem install sixarm_ruby_string_to_class -v ">= 1.1.1, < 2"

To install using the command line with high security, run this:

wget http://sixarm.com/sixarm.pem
gem cert --add sixarm.pem && gem sources --add http://sixarm.com
gem install sixarm_ruby_string_to_class -v ">= 1.1.1, < 2" --trust-policy HighSecurity

To require the gem in your code:

require "sixarm_ruby_string_to_class"

Examples

"Foo".to_class  #=> Foo class
"MyModule::MyClass".to_class  #=> MyModule::MyClass class

More

For docs go to http://sixarm.com/sixarm_ruby_string_to_class/doc

Want to help? We're happy to get pull requests.