I have this:
-----------
case child.name
when @collection.location_tag
@article.location = child.content
when @collection.content_tag
@article.content = child.content
when @collection.docno_tag
@article.docno = child.content
when @collection.date_tag
temp_date = child.content
end
-----------
is there a way to check whether the @collection.attributes are empty
or not before to evaluate them in the "When" clause?
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
2009/12/22 adedip <adedip-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> I have this: > ----------- > case child.name > when @collection.location_tag > @article.location = child.content > when @collection.content_tag > @article.content = child.content > when @collection.docno_tag > @article.docno = child.content > when @collection.date_tag > temp_date = child.content > end > ----------- > > is there a way to check whether the @collection.attributes are empty > or not before to evaluate them in the "When" clause?I don''t understand what you mean, can you be more explicit? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
sorry..: P I meant this:
I have a record saved in the @collection variable
i.e. @collection = Collection.find(1)
I''m using nokogiri parser to add content of certain tag in the
collection into a new Article..
it happen sometimes that a field of the article is not available in
the collection..so I need to check before to "case" if it''s
not empty
So I have for istance:
Collection {name:string, title_tag:string, content_tag:string,
author_tag:string, ... }
Article{title:string,content:text,author:string, ... }
in the parser i want to add (dynamically) the collections tags
associated to Articles field
I''m not sure that each of the Collection field_tag is given.. and
before to do
Case ''TAG''
When ''TAGNAME''
I''d want to check if the tag_field attribute is empty or not
I guess something like this:
case child.name
*unless @collection.location_tag.empty?*
when @collection.location_tag
@article.location = child.content
*unless @collection.content_tag.empty?*
when @collection.content_tag
@article.content = child.content
*unless @collection.docno_tag.empty?*
when @collection.docno_tag
@article.docno = child.content
*unless @collection.date_tag.empty?*
when @collection.date_tag
temp_date = child.content
end
but I hope exists a better way to do that instead using "unless"
(I''m
not even sure it works..)
did i make it clearer? hope so.. :)
thx
On Dec 22, 5:21 pm, Colin Law
<clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> 2009/12/22 adedip <ade...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
>
>
> > I have this:
> > -----------
> > case child.name
> > when @collection.location_tag
> > @article.location = child.content
> > when @collection.content_tag
> > @article.content = child.content
> > when @collection.docno_tag
> > @article.docno = child.content
> > when @collection.date_tag
> > temp_date = child.content
> > end
> > -----------
>
> > is there a way to check whether the @collection.attributes are empty
> > or not before to evaluate them in the "When" clause?
>
> I don''t understand what you mean, can you be more explicit?
>
> Colin
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 23, 9:44 am, adedip <ade...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> sorry..: P I meant this: > > I have a record saved in the @collection variable > i.e. @collection = Collection.find(1) > > I''m using nokogiri parser to add content of certain tag in the > collection into a new Article.. > it happen sometimes that a field of the article is not available in > the collection..so I need to check before to "case" if it''s not empty > > So I have for istance: > > Collection {name:string, title_tag:string, content_tag:string, > author_tag:string, ... } > Article{title:string,content:text,author:string, ... } > > in the parser i want to add (dynamically) the collections tags > associated to Articles field > > I''m not sure that each of the Collection field_tag is given.. and > before to do > > Case ''TAG'' > When ''TAGNAME'' > > I''d want to check if the tag_field attribute is empty or not > > I guess something like this: > > case child.name > *unless @collection.location_tag.empty?* > when @collection.location_tag > -kF9HwRviZLTS2ROB2qTZ6Q@public.gmane.org = child.content > *unless @collection.content_tag.empty?* > when @collection.content_tag > -kF9HwRviZLQbwp1Q5LbLBw@public.gmane.org = child.content > *unless @collection.docno_tag.empty?* > when @collection.docno_tag > -kF9HwRviZLSgZro1biPblw@public.gmane.org = child.content > *unless @collection.date_tag.empty?* > when @collection.date_tag > temp_date = child.content > end > > but I hope exists a better way to do that instead using "unless" (I''m > not even sure it works..) > > did i make it clearer? hope so.. :) > thxThe most obvious thing that comes to mind is that if "child.name" isn''t empty, it''s never going to much an empty tag attribute... -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2009/12/23 adedip <adedip-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> sorry..: P I meant this: > > I have a record saved in the @collection variable > i.e. @collection = Collection.find(1) > > I''m using nokogiri parser to add content of certain tag in the > collection into a new Article.. > it happen sometimes that a field of the article is not available in > the collection..so I need to check before to "case" if it''s not empty > > So I have for istance: > > Collection {name:string, title_tag:string, content_tag:string, > author_tag:string, ... } > Article{title:string,content:text,author:string, ... } > > in the parser i want to add (dynamically) the collections tags > associated to Articles field > > I''m not sure that each of the Collection field_tag is given.. and > before to do > > Case ''TAG'' > When ''TAGNAME'' > > I''d want to check if the tag_field attribute is empty or not > > I guess something like this: > > case child.name > *unless @collection.location_tag.empty?*You don''t need to test for empty? because if it is empty it will never match in the ''when'' (unless child.name is also empty which presumably it is not) Colin> when @collection.location_tag > @article.location = child.content > *unless @collection.content_tag.empty?* > when @collection.content_tag > @article.content = child.content > *unless @collection.docno_tag.empty?* > when @collection.docno_tag > @article.docno = child.content > *unless @collection.date_tag.empty?* > when @collection.date_tag > temp_date = child.content > end > > but I hope exists a better way to do that instead using "unless" (I''m > not even sure it works..) > > did i make it clearer? hope so.. :) > thx > > On Dec 22, 5:21 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> 2009/12/22 adedip <ade...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >> >> >> > I have this: >> > ----------- >> > case child.name >> > when @collection.location_tag >> > @article.location = child.content >> > when @collection.content_tag >> > @article.content = child.content >> > when @collection.docno_tag >> > @article.docno = child.content >> > when @collection.date_tag >> > temp_date = child.content >> > end >> > ----------- >> >> > is there a way to check whether the @collection.attributes are empty >> > or not before to evaluate them in the "When" clause? >> >> I don''t understand what you mean, can you be more explicit? >> >> Colin > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks, in this way is much easier :D Merry xmas btw ;) On 23 Dic, 17:01, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 2009/12/23 adedip <ade...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > sorry..: P I meant this: > > > I have a record saved in the @collection variable > > i.e. @collection = Collection.find(1) > > > I''m using nokogiri parser to add content of certain tag in the > > collection into a new Article.. > > it happen sometimes that a field of the article is not available in > > the collection..so I need to check before to "case" if it''s not empty > > > So I have for istance: > > > Collection {name:string, title_tag:string, content_tag:string, > > author_tag:string, ... } > > Article{title:string,content:text,author:string, ... } > > > in the parser i want to add (dynamically) the collections tags > > associated to Articles field > > > I''m not sure that each of the Collection field_tag is given.. and > > before to do > > > Case ''TAG'' > > When ''TAGNAME'' > > > I''d want to check if the tag_field attribute is empty or not > > > I guess something like this: > > > case child.name > > *unless @collection.location_tag.empty?* > > You don''t need to test for empty? because if it is empty it will never > match in the ''when'' (unless child.name is also empty which presumably > it is not) > > Colin > > > when @collection.location_tag > > @article.location = child.content > > *unless @collection.content_tag.empty?* > > when @collection.content_tag > > @article.content = child.content > > *unless @collection.docno_tag.empty?* > > when @collection.docno_tag > > @article.docno = child.content > > *unless @collection.date_tag.empty?* > > when @collection.date_tag > > temp_date = child.content > > end > > > but I hope exists a better way to do that instead using "unless" (I''m > > not even sure it works..) > > > did i make it clearer? hope so.. :) > > thx > > > On Dec 22, 5:21 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> 2009/12/22 adedip <ade...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > >> > I have this: > >> > ----------- > >> > case child.name > >> > when @collection.location_tag > >> > @article.location = child.content > >> > when @collection.content_tag > >> > @article.content = child.content > >> > when @collection.docno_tag > >> > @article.docno = child.content > >> > when @collection.date_tag > >> > temp_date = child.content > >> > end > >> > ----------- > > >> > is there a way to check whether the @collection.attributes are empty > >> > or not before to evaluate them in the "When" clause? > > >> I don''t understand what you mean, can you be more explicit? > > >> Colin > > > -- > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.