The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
ActiveSupport::CoreExtensions::String::Inflections underscore

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jake Scruggs

Posts: 336
Nickname: aurorae314
Registered: Feb, 2008

Jake Scruggs is a developer at ThoughtWorks
ActiveSupport::CoreExtensions::String::Inflections underscore Posted: Feb 21, 2008 4:55 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jake Scruggs.
Original Post: ActiveSupport::CoreExtensions::String::Inflections underscore
Feed Title: Jake Scruggs
Feed URL: http://jakescruggs.blogspot.com/feeds/posts/default
Feed Description: Ruby, Rails, Metrics, Testing, and pursuit of clean code.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jake Scruggs
Latest Posts From Jake Scruggs

Advertisement

>> "ActiveSupport::CoreExtensions::String::Inflections".underscore
=> "active_support/core_extensions/string/inflections"

>> "ActiveSupport::CoreExtensions::String::Inflections".underscore.camelize
=> "ActiveSupport::CoreExtensions::String::Inflections"

Looks like Rails extension to the string class does more than underscore a string. Which is useful, but shouldn't the name be "relative_path" or something similar? When I see the method name "underscore" I know exactly what it means, except that's not what it does. The opposite of "underscore" is "camelize " which, again, may not have the best name.

And if you want to find the declared constant specified in a string:
>> "ActiveSupport::CoreExtensions::String::Inflections".constantize
=> ActiveSupport::CoreExtensions::String::Inflections
Useful and an excellent name.

Read: ActiveSupport::CoreExtensions::String::Inflections underscore

Topic: The Value of the Data Cloud Previous Topic   Next Topic Topic: Rake: Task Overwriting

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use