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/
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 ? On 1/27/06, Duane Johnson <duane.johnson@gmail.com> 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" > > "(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/ > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060128/785112f7/attachment.html
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/
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 -- Posted via http://www.ruby-forum.com/.
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 --- On 1/27/06, Kevin Olbrich <kevin.olbrich@duke.edu> wrote:> > 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060128/535d40da/attachment-0001.html
On Jan 27, 2006, at 5:59 PM, Rabbit wrote:> 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 >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/
permalink? -Ezra On Jan 27, 2006, at 4: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 ? > > > > > On 1/27/06, Duane Johnson <duane.johnson@gmail.com> 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" > > "(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/ > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com
On 1/27/06, Duane Johnson <duane.johnson@gmail.com> 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" > > "(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/ > > > _______________________________________________ > 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
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? -- Alex
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060128/fcc0ec81/attachment-0001.html
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> 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 > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060128/63d59b6b/attachment.html
+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> 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 > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060128/50717eef/attachment.html
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 _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060129/261ef0dc/attachment.html