execute script in context of a member method

A

Achim Domma

Hi,

I have a class wrapping some watir code, which can be used like:

app = HelperClass.new(...)
app.login "user","user"
app.textbox 3, "some text"
app.save

I want to split this into a runner script and a script which looks like:

login "user","user"
textbox 3, "some text"
save

I think this should be possible without too much effort in ruby, but I
don't get it. Any hint is very welcome!

regards,
Achim
 
R

Robert Klemme

Achim said:
Hi,

I have a class wrapping some watir code, which can be used like:

app = HelperClass.new(...)
app.login "user","user"
app.textbox 3, "some text"
app.save

I want to split this into a runner script and a script which looks like:

login "user","user"
textbox 3, "some text"
save

I think this should be possible without too much effort in ruby, but I
don't get it. Any hint is very welcome!

regards,
Achim

app = Helper.new

app.instance_eval do
login "user","user"
textbox 3, "some text"
save
end

robert
 
A

Achim Domma

Robert said:
app.instance_eval do
login "user","user"
textbox 3, "some text"
save
end

Thanks! I changed it to app.instance_eval(IO.read("inc.rb")). That's
exactly what I was looking for.

Achim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,677
Latest member
MoisesKoeh

Latest Threads

Top