Ah,  you're using a class variable and you have no accessor methods so it's
only available to . You'll need to add a class accessor or an instance
method if you're creating object of type LoginInput to get at the value:

class LoginInput
 @@user_name = "Vipul.Goyal"

 def LoginInput.user_name
   @@user_name
 end
end

puts LoginInput.user_name
=> "Vipul.Goyal"

# Now with instance:
class LoginInput
 @@user_name = "Vipul.Goyal"

 def user_name
   @@user_name
 end
end

l = LoginInput.new
puts l.user_name
=> "Vipul.Goyal"



-Charley

On 5/14/07, aidy lewis <[EMAIL PROTECTED]> wrote:

>On 14/05/07, Vipul <[EMAIL PROTECTED]> wrote:

> class LoginInput
>    @@userName = "Vipul.Goyal"
>  end


> $ie.text_field(:id,"txtLoginID").set(LoginInput.userName)


I think the OO idea is that the client should not be able to directly
access a variable outside a class.

<code>
class Login_Input
  attr_reader :user_name
  def initialize
    @user_name = "Vipul.Goyal"
  end
end

login_input = Login_Input.new
p login_input.user_name
</code>

Though, I would be interested in other opinions on this.


aidy
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to