How to get a constant name by file name

Given the file name, I would like to know if there is a ruby ​​way to get a constant name for it.

eg:

"lib/myproject/connect.rb" => MyProject::Connect

ps: I know I can create a script for this.

EDIT: consider only the first one at the top.

+3
source share
1 answer

You can take a look at the implementation Inflector#camelizein ActiveSupport, see: http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-camelize

+3
source

All Articles