Using a user defined variable within a function? (Ruby, Watir)

I'm creating drag and drop feature that depends on upon ID for placement, it works perfectly fine, but I need the status of task to be user defined so the user will have control of where something will be dragged as each section is uniquely named.

getID refers to getting the reference id of a Div.

I'd then concatenating with a "_" as well as adding the user set word


def addtask
    dropTask = @browser.div(:id => getID+"_"+"@#{statusOfTask}")
    dragTask = @browser.div(:id, "footer").span(:class, "headerDrag")
    dragTask.drag_and_drop_on dropTask 

User Script:

statusOfTask = ["Ready"]

Any ideas?


You just need to pass the desired status text to the addTask() method.

Class (add statusOfTask as a parameter):

def addtask(statusOfTask)
    dropTask = @browser.div(:id => getID+"_"+"@#{statusOfTask}")
    dragTask = @browser.div(:id, "footer").span(:class, "headerDrag")
    dragTask.drag_and_drop_on dropTask 

User Script (pass in the first (or desired) value of statusOfTask):

statusOfTask = ["Ready"]

Need Your Help

Cannot access excel file

c# excel windows-services interop

I'm developing a windows service, generating a report. This report has a template. This template is prepared in an excel file. This file is copied to the output folder.

reference on Object which was transfered as parameter

java object reference

3rd Code Sample contains the error - how to solve? In the following code I have generated a method called "generator". This method receives a JTextField and a JLabel as parameter. It generates

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.