Adam,

I'm building a collection of transformations which can be described as
chained method invocations. How do you extract related entities from
an nokogiri document of an amazon review page? By applying these
transformations:
https://github.com/derdewey/amzn-scraper/blob/master/amazon_review.rb
. Find a common node to describe the entity, then extract each of the
elements and return a handy hash.

Ben,

So that works when it's being passed directly to send but it won't
work when passed in from a splatted array!

    [1,2,3].send(*[:collect, &Proc.new{|x| x.to_s + "!"}])
    -> SyntaxError: (irb):1: expecting ']'

My workaround, which is kinda lame, is to just extend the nokogiri class.

Xavier

On Mon, Jan 31, 2011 at 7:06 PM, Adam Grant <[email protected]> wrote:
> Any reason why you aren't calling "collect" directly from the Array?
> _
> Adam
>
>
> On Mon, Jan 31, 2011 at 4:50 PM, Xavier Lange <[email protected]> wrote:
>>
>> I'm building a HTML extractor on top of nokogiri which applies a
>> collection of CSS search strings and more to build a logical
>> extraction of data and I wanted to use something like this:
>>
>> [1,2,3].send(:collect,Proc.new{|x| x.to_s + "!"})
>>
>> This fails. Any ideas how I could work around this? How do you use
>> Object#send (or similar) with a block?
>>
>> Xavier
>>
>> --
>> SD Ruby mailing list
>> [email protected]
>> http://groups.google.com/group/sdruby
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to