I’m doing some code generation and need to convert from CamelCase to
whatever_this_is_called. Wikipedia has a page for CamelCase but not
underscore separated words.
I’m thinking that someone must have done this already, and got the
edge cases sorted out, so rather than coming up with a wheel with an
iron tyre I’d search… for what? Is there a single correct term
for how we name methods in Ruby?
Ruby on Rails have similar things. You should take a look at Active
Support, and particulary the
ActiveSupport::CoreExtensions::String::Inflections class. The
“underscore” method can be used to transform a string from CamelCase to
underscore_seprated_words.
Ruby on Rails have similar things. You should take a look at Active Support,
and particulary the ActiveSupport::CoreExtensions::String::Inflections class.
The “underscore” method can be used to transform a string from CamelCase to
underscore_seprated_words.
Thank you. That’s splendid.
–
Bruno M.
Hugh
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.