Two properties with the same name


(Maurício) #1

Hi,

I'm using Ruby with WIN32OLE. I've created an OLE object that has a

property named “type”. I want to see it’s value but, when I try, I get:

irb(main):008:0> element.type
WIN32OLE

How can I access the value of the "type" property (in this example, it's

supposed to be 25) instead of WIN32OLE?

Thanks,
Maurício

(Yohanes Santoso) #2

“Maurício” briqueabraque@yahoo.com writes:

Hi,

I'm using Ruby with WIN32OLE. I've created an OLE object that has a

property named “type”. I want to see it’s value but, when I try, I get:

irb(main):008:0> element.type
WIN32OLE

How can I access the value of the "type" property (in this example, it's

supposed to be 25) instead of WIN32OLE?

This calls the #type method inherited from Object. If you want to
override it, then do this:

alias_method :orig_type :type
def element.type
element[‘type’]
end
def element.type=(newType)
element[‘type’]=newType
end

so, when called:

element.type
25
element.orig_type
WIN32OLE
element.type = 5
5
element.type
5

YS.


(Nobuyoshi Nakada) #3

Hi,

···

At Wed, 26 Jun 2002 04:24:32 +0900, Yohanes Santoso wrote:

How can I access the value of the "type" property (in this example, it's

supposed to be 25) instead of WIN32OLE?

This calls the #type method inherited from Object. If you want to

Object#type is old name for Object#class, and you can undefine
it.

class << element; undef_method :type; end

or

WIN32OLE.module_eval {undef type}


Nobu Nakada