Reputation: 8240
Given a filename, I would like to know if there is a ruby way to obtain the constant name for it.
e.g:
"lib/myproject/connect.rb"
=> MyProject::Connect
p.s: I know I can create a script for this.
EDIT: consider only the first one at the top.
Upvotes: 3
Views: 357
Reputation: 106882
You may wanna take a look at the implementation of Inflector#camelize
in ActiveSupport
, see: http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-camelize
Upvotes: 3