Forum: Ruby on Rails What's the verb form of id?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2006-01-28 01:34
(Received via mailing list)
Random question:

I've written a method for the String class that turns an arbitrary
line of text in to an identifier, e.g.:

"My, what a beautiful day!"
=> "my_what_a_beautiful_day"

"(anb*#NF(AMNV"
=> "anb_NF_AMNV"

We've got all these great names already like underscore, classify,
titleize and things like that.  I'd like to name my new method
similarly.  What would the verb form of id, or identifier, be?

idize
identifize
identitize

Maybe?


Duane Johnson
(canadaduane)
http://blog.inquirylabs.com/
Ff82af3238a57fbd1212832ec1a19f28?d=identicon&s=25 Dylan Stamat (Guest)
on 2006-01-28 01:37
(Received via mailing list)
verify_identificality_of ....  haha... j/k of course.  i vote for:
identifize
how are you using it ?  would it be worth adding to Inflector maybe ?
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2006-01-28 01:52
(Received via mailing list)
On Jan 27, 2006, at 5:36 PM, Dylan Stamat wrote:

> verify_identificality_of ....  haha... j/k of course.  i vote for:
> identifize
> how are you using it ?  would it be worth adding to Inflector maybe ?
>
>
I'm using it in a helper method that takes the title of a
"section" (e.g., a <div>) and creates a javascript-friendly 'id' out
of it.  For example:

<% section 'Tell Us About Yourself' do %>
  ... form goes here ...
<% end %>

produces:

<h1>Tell Us About Yourself</h1>
<div id='tell_us_about_yourself'>
  ... form goes here ...
</div>

It's the first time I've had a need for this, but if it's generally
useful, I could submit a patch...

Duane Johnson
(canadaduane)
http://blog.inquirylabs.com/
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (olbrich)
on 2006-01-28 01:55
Duane Johnson wrote:
> Random question:
>
> I've written a method for the String class that turns an arbitrary
> line of text in to an identifier, e.g.:
>
> "My, what a beautiful day!"
> => "my_what_a_beautiful_day"
>
How about :

"rubify" since you are basically making it a ruby-style indentifier

_Kevin
42292bf8a0acbc98862d9306b501275d?d=identicon&s=25 Daniel Waite (rabbitcreative)
on 2006-01-28 02:01
(Received via mailing list)
Ah... I like "rubify." I actually wrote a function that did just this a
couple days ago. I called it "variableize" though. "rubify" is much,
much
better!

Here's the code, if anyone's interested :)

class Inflector
    def self.rubify string
        string.gsub(/\s/, '_').downcase
    end
end

Example:

Inflector::rubify "Rabbit Blue" # rabbit_blue

- Rabbit

---
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2006-01-28 02:31
(Received via mailing list)
On Jan 27, 2006, at 5:59 PM, Rabbit wrote:

> end
>
> Example:
>
> Inflector::rubify "Rabbit Blue" # rabbit_blue
>
> - Rabbit
>

I like the name too.  Here's the modified String class.  This one
squeezes non-alphanumeric character sequences down to one underscore
and also makes sure it doesn't start or end with an underscore:

class String
   def rubify
     downcase.gsub(/\W/, ' ').squeeze.strip.gsub(' ', '_')
   end

   def rubify!
     replace rubify
   end
end

"!Hell93 o3#$@ the___re , dude".rubify
=> "hel93_o3_the_re_dude"


Duane Johnson
(canadaduane)
http://blog.inquirylabs.com/
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-01-28 02:37
(Received via mailing list)
permalink?

-Ezra
On Jan 27, 2006, at 4:36 PM, Dylan Stamat wrote:

> I've written a method for the String class that turns an arbitrary
> similarly.  What would the verb form of id, or identifier, be?
> http://blog.inquirylabs.com/
> http://lists.rubyonrails.org/mailman/listinfo/rails
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-01-28 02:49
(Received via mailing list)
On 1/27/06, Duane Johnson <duane.johnson@gmail.com> wrote:
>
>
> Duane Johnson
> (canadaduane)
> http://blog.inquirylabs.com/
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

In file_column, that method is called sanitize.

--
Kyle Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-01-28 19:08
(Received via mailing list)
Duane Johnson wrote:
> We've got all these great names already like underscore, classify,
> titleize and things like that.  I'd like to name my new method
> similarly.  What would the verb form of id, or identifier, be?
>
identify, surely?
1e99128ebac5ca41c91940291d315332?d=identicon&s=25 Luke Redpath (Guest)
on 2006-01-28 22:03
(Received via mailing list)
ID is short for identification the related verb of which is identify, as
Alex pointed out.

The appropriate verify_ macro would be verify_identity_of

Looking at your original examples perhaps you don't mean verb form but
you
mean what word should you use for the process of turning something into
its
identity form?

If thats the case, I'd avoid the mangling of the English language that
some
Rails methods take, and use the more conventional Ruby idiom, to_id()
(like
to_s, to_i etc.).

"My, what a beautiful day!".to_id
=> "my_what_a_beautiful_day"

If thats not clear enough or possibly confusing with the normal use of
id in
a Rails app, perhaps to_identifier() instead.

Cheers
Luke
42292bf8a0acbc98862d9306b501275d?d=identicon&s=25 Daniel Waite (rabbitcreative)
on 2006-01-28 23:58
(Received via mailing list)
Hey Duane Johnson I like your method better! :) Thanks for sharing.

I gotta agree with Luke on the Rubyesque idiom, much cleaner. I shall
change
my code accordingly.

Good discussion. :)

- Rabbit

---
Ff82af3238a57fbd1212832ec1a19f28?d=identicon&s=25 Dylan Stamat (Guest)
on 2006-01-29 00:13
(Received via mailing list)
+1 on Luke's comment.  I'm too lazy to think rationaly about the english
language like he did... but he made some good points :)
Af93ba6b6b59f22a8f37e8de5702ef98?d=identicon&s=25 Bob Silva (Guest)
on 2006-01-29 02:31
(Received via mailing list)
This would be nice to have in the Inflector Class in core. Adding this
as a
method of the String class probably wont make it into core if submitted.



Just something to think about.



How about sanctify ? It's kinda like your cleansing it of its sins.





Bob Silva

http://www.railtie.net/





  _____

From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Dylan Stamat
Sent: Saturday, January 28, 2006 3:13 PM
To: rails@lists.rubyonrails.org
Subject: Re: [Rails] What's the verb form of id?



+1 on Luke's comment.  I'm too lazy to think rationaly about the english
language like he did... but he made some good points :)



On 1/28/06, Rabbit < rabbitblue@gmail.com> wrote:

Hey Duane Johnson I like your method better! :) Thanks for sharing.

I gotta agree with Luke on the Rubyesque idiom, much cleaner. I shall
change
my code accordingly.

Good discussion. :)

- Rabbit

---

On 1/28/06, Luke Redpath < contact@lukeredpath.co.uk
<mailto:contact@lukeredpath.co.uk> > wrote:

ID is short for identification the related verb of which is identify, as
Alex pointed out.

The appropriate verify_ macro would be verify_identity_of

Looking at your original examples perhaps you don't mean verb form but
you
mean what word should you use for the process of turning something into
its
identity form?

If thats the case, I'd avoid the mangling of the English language that
some
Rails methods take, and use the more conventional Ruby idiom, to_id()
(like
to_s, to_i etc.).

"My, what a beautiful day!".to_id
=> "my_what_a_beautiful_day"

If thats not clear enough or possibly confusing with the normal use of
id in
a Rails app, perhaps to_identifier() instead.

Cheers
Luke




_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (olbrich)
on 2006-01-29 06:00
Bob Silva wrote:
> How about sanctify ? It's kinda like your cleansing it of its sins.

Then maybe it should be 'exorcise'.  Hmm.. I need more of that anyway.

_Kevin
This topic is locked and can not be replied to.