The purpose of classes and objects (which are created from classes) is to encapsulate data. In your example, you are on encapsulating data, so you correct in saying that a module is as good as a class.

This gives you the encapsulation:

class ObjectMap
 def new ie; @ie = ie; end
 def login_link;$ie.link(:text, 'Log in');end
 def logout_link;$ie.link(:text, 'Log out');end
end

Then

 map = ObjectMap.new $ie
 map.login_link.click
 map.logout_link.click

And if you want a cleaner syntax you can do...

ObjectMap.new($ie).instance_eval do
  login_link.click
  logout_link.click
end

Bret

On 7/14/06, Adrian Rutter <[EMAIL PROTECTED]> wrote:

Instead of having a class map

i.e.

class ObjectMap
  def login_link;$ie.link(:text, 'Log in');end
  def logout_link;$ie.link(:text, 'Log out');end
end

Then

  map = ObjectMap.new
  map.login_link.click
  map.logout_link.click

  why not put the app map in a module

  so in the script we could just go

  login_link.click
  logout_link.click    ?

  Cheers

  aidy

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

Reply via email to