does someone knows if there is method which checks both? if not then i''ll write my own .. but i am curious if there is one for return x.nil? or blank? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 6, 2007, at 1:03 PM, Michal Gabrukiewicz wrote:> does someone knows if there is method which checks both? if not then > i''ll write my own .. but i am curious if there is one for > > return x.nil? or blank?(x.nil? or x.blank?) is logically equivalent to x.blank? because nil is blank: nil.blank? # -> true So the answer is yes, you are looking for blank? indeed :-). -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
oh thanks ... thats good to know ;) great! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
After a quick test it appears that Rails must add the blank? method to nil. Ruby "out-of-the-box" reports that nil has no blank? method. Just FYI. On Dec 6, 7:13 am, Michal Gabrukiewicz <rails-mailing-l...@andreas- s.net> wrote:> oh thanks ... thats good to know ;) > great! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
According to: http://noobkit.com/show/ruby/rails/rails-stable/activesupport/object/blank-3f.html ActiveSupport is what includes the method. All the code it uses is pretty simple: def blank? if respond_to?(:empty?) && respond_to?(:strip) empty? or strip.empty? elsif respond_to?(:empty?) empty? else !self end end On Dec 7, 2007 4:58 PM, Robert Walker <rwalker348-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > After a quick test it appears that Rails must add the blank? method to > nil. Ruby "out-of-the-box" reports that nil has no blank? method. Just > FYI. > > On Dec 6, 7:13 am, Michal Gabrukiewicz <rails-mailing-l...@andreas- > s.net> wrote: > > oh thanks ... thats good to know ;) > > great! > > -- > > Posted viahttp://www.ruby-forum.com/. > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I want one that checks for empty + empty array.... On Dec 6, 10:34 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> According to: > > http://noobkit.com/show/ruby/rails/rails-stable/activesupport/object/... > > ActiveSupport is what includes the method. > I w > All the code it uses is pretty simple: > > def blank? > if respond_to?(:empty?) && respond_to?(:strip) > empty? or strip.empty? > elsif respond_to?(:empty?) > empty? > else > !self > end > end > > On Dec 7, 2007 4:58 PM, Robert Walker <rwalker...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > After a quick test it appears that Rails must add the blank? method to > > nil. Ruby "out-of-the-box" reports that nil has no blank? method. Just > > FYI. > > > On Dec 6, 7:13 am, Michal Gabrukiewicz <rails-mailing-l...@andreas- > > s.net> wrote: > > > oh thanks ... thats good to know ;) > > > great! > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > -- > Ryan Bigghttp://www.frozenplague.net--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 7, 2007, at 8:20 AM, eggie5 wrote:> I want one that checks for empty + empty array....That''s blank? again. In Rails blank? has an implementation in Object and a few special cases. For example in Array class Array #:nodoc: alias_method :blank?, :empty? end In NilClass it returns true directly: class NilClass #:nodoc: def blank? true end end And there are a few more. See activesupport/lib/active_support/ core_ext/blank.rb. -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michal Gabrukiewicz wrote:> does someone knows if there is method which checks both? if not then > i''ll write my own .. but i am curious if there is one for > > return x.nil? or blank?x.blank? is equivalent to x.nil? or x.empty? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yeah as far as i see our guy is blank? ... www.webdevbros.net - ruby, rails & co. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
oh duh.... On Dec 7, 2:07 am, Xavier Noria <f...-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:> On Dec 7, 2007, at 8:20 AM, eggie5 wrote: > > > I want one that checks for empty + empty array.... > > That''s blank? again. > > In Rails blank? has an implementation in Object and a few special > cases. For example in Array > > class Array #:nodoc: > alias_method :blank?, :empty? > end > > In NilClass it returns true directly: > > class NilClass #:nodoc: > def blank? > true > end > end > > And there are a few more. See activesupport/lib/active_support/ > core_ext/blank.rb. > > -- fxn--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---