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.
Duane J. (Guest)
on 2006-01-28 02: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 J.
(canadaduane)
http://blog.inquirylabs.com/
Dylan S. (Guest)
on 2006-01-28 02: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 ?
Duane J. (Guest)
on 2006-01-28 02:52
(Received via mailing list)
On Jan 27, 2006, at 5:36 PM, Dylan S. 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 J.
(canadaduane)
http://blog.inquirylabs.com/
Kevin O. (Guest)
on 2006-01-28 02:55
Duane J. 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
Daniel W. (Guest)
on 2006-01-28 03: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

---
Duane J. (Guest)
on 2006-01-28 03: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 J.
(canadaduane)
http://blog.inquirylabs.com/
Ezra Z. (Guest)
on 2006-01-28 03:37
(Received via mailing list)
permalink?

-Ezra
On Jan 27, 2006, at 4:36 PM, Dylan S. 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 Z.
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
removed_email_address@domain.invalid
Kyle M. (Guest)
on 2006-01-28 03:49
(Received via mailing list)
On 1/27/06, Duane J. <removed_email_address@domain.invalid> wrote:
>
>
> Duane J.
> (canadaduane)
> http://blog.inquirylabs.com/
>
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

In file_column, that method is called sanitize.

--
Kyle M.
Chief Technologist
E Factor Media // FN Interactive
removed_email_address@domain.invalid
1-866-263-3261
Alex Y. (Guest)
on 2006-01-28 20:08
(Received via mailing list)
Duane J. 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?
Luke R. (Guest)
on 2006-01-28 23: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
Daniel W. (Guest)
on 2006-01-29 00:58
(Received via mailing list)
Hey Duane J. 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

---
Dylan S. (Guest)
on 2006-01-29 01: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 :)
Bob S. (Guest)
on 2006-01-29 03: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 S.

http://www.railtie.net/





  _____

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Dylan S.
Sent: Saturday, January 28, 2006 3:13 PM
To: removed_email_address@domain.invalid
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 < removed_email_address@domain.invalid> wrote:

Hey Duane J. 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 R. < removed_email_address@domain.invalid
<mailto:removed_email_address@domain.invalid> > 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
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails
Kevin O. (Guest)
on 2006-01-29 07:00
Bob S. 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.