Title: Re: [Wtr-general] Method Names as variables?

Hi Michael, yes, sorry for that…

I’ve translated the variable names to english (I’m from Argentina), but I forgot that todosdocs…

 

Cheers!

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Bolton
Sent: Martes, 18 de Abril de 2006 06:03 p.m.
To: [email protected]
Subject: Re: [Wtr-general] Method Names as variables?

 

You may be too bilingual; I see where alldocs is initialized, but I don't see where todosdocs is initialized.

 

---Michael B.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodrigo Julian Martin
Sent: April 18, 2006 4:27 PM
To: [email protected]
Subject: Re: [Wtr-general] Method Names as variables?

Hello Keith!

Thanks for the quick answer, but I’m afraid that this is not what I’m looking for…

I have written a function which search objects from a page, passing a propertie and a value as parameters…

 

This is the function:

 

 

def ENRA_FindObjects(propertie, value)

   $vector_fobjects=nil

   $vector_fobjects=Array.new

   j=0

   alldocs=nil

   alldocs=$browser.document.body.all

   count=$browser.document.body.all.length

   $vector_search=nil

   $vector_search=Array.new

   for i in 0..count-1 do

      if (todosdocs[i.to_s].”#{propertie}=="#{value}")

            $vector_search[j]=todosdocs[i.to_s]

            j+=1

        end

   end

   return($vector_search)

end

 

So, I load a page with a browser, and execute this function with, let’s say:

 

array_objects=ENRA_FindObjects(“className”,”button”)

 

I hope the question is more clear now…

 

How can I write this properly? à  todosdocs[i.to_s].”#{propertie}=="#{value}" ,

In order that the propertie could be defined by a parameter?

 

 

Thank you so much for your time…

Cheers

 

Rodrigo Julian Martin


From: Keith Lancaster [mailto:[EMAIL PROTECTED]
Sent: Martes, 18 de Abril de 2006 05:17 p.m.
To: [email protected]; Rodrigo Julian Martin
Subject: Re: [Wtr-general] Method Names as variables?

 

I am assuming Item(80) in your example is an object.

In Ruby, you can use the “send” method to call a function.

Example:

class MyClass
    def my_function
        puts “in my function”
    end
end

c = MyClass.new
function_name = “my_function”
c.send(function_name)

HTH,
Keith



On 4/18/06 3:00 PM, "Rodrigo Julian Martin" <[EMAIL PROTECTED]> wrote:

Hello!
 
I have another code question…
 
Can I call an object method by using a variable?
 
I’ve tried something like this:
 
 
propertie=”className”
a = Item(80).’#{propertie}’
 
And obviously doesn’t work…
 
I’ve also tried:
 
a = Item(80).{propertie}
 
but this is a call to a hash…
 
 
Any help would be really appreciated…
Thanks in Advance!
 
 
Rodrigo Julian Martin


_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

 

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to