diff --git a/ChangeLog b/ChangeLog index 33adee467d..b2acfdb89b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Jan 7 17:47:16 2007 Masaki Suketa + + * test/win32ole/test_win32ole.rb: add test for WIN32OLE#[], + WIN32OLE#[]=. + + * ext/win32ole/win32ole.c: update comment for rdoc of + WIN32OLE#[] and WIN32OLE#[]=. + Sun Jan 7 12:13:26 2007 Eric Hodel * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment): diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index ea2fe62c4c..053bb2f813 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -2746,10 +2746,20 @@ fole_setproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types) /* * call-seq: - * WIN32OLE['property']=val - * WIN32OLE.setproperty('property', [arg1, arg2,...] val) + * WIN32OLE[a1, a2, ...]=val * - * Sets property of OLE object. + * Sets the value to WIN32OLE object specified by a1, a2, ... + * + * dict = WIN32OLE.new('Scripting.Dictionary') + * dict.add('ruby', 'RUBY') + * dict['ruby'] = 'Ruby' + * puts dict['ruby'] # => 'Ruby' + * + * Remark: You can not use this method to set the property value. + * + * excel = WIN32OLE.new('Excel.Application') + * # excel['Visible'] = true # This is error !!! + * excel.Visible = true # You should to use this style to set the property. * */ static VALUE @@ -2780,12 +2790,19 @@ fole_setproperty(int argc, VALUE *argv, VALUE self) /* * call-seq: - * WIN32OLE['property'] + * WIN32OLE[a1,a2,...] * - * Returns property of OLE object. + * Returns the value of Collection specified by a1, a2,.... * + * dict = WIN32OLE.new('Scripting.Dictionary') + * dict.add('ruby', 'Ruby') + * puts dict['ruby'] # => 'Ruby' (same as `puts dict.item('ruby')') + * + * Remark: You can not use this method to get the property. * excel = WIN32OLE.new('Excel.Application') - * puts excel['Visible'] # => false + * # puts excel['Visible'] This is error !!! + * puts excel.Visible # You should to use this style to get the property. + * */ static VALUE fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self) diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb index f1bdb2c208..df7a9abfd7 100644 --- a/test/win32ole/test_win32ole.rb +++ b/test/win32ole/test_win32ole.rb @@ -40,5 +40,19 @@ if defined?(WIN32OLE) name = folder.getDetailsOf({"vItem" => item, :iColumn => 0}) assert_equal(item.name, name) end + + def test_bracket + dict = WIN32OLE.new('Scripting.Dictionary') + dict.add("foo", "FOO") + assert_equal("FOO", dict.item("foo")) + assert_equal("FOO", dict["foo"]) + end + + def test_bracket_equal + dict = WIN32OLE.new('Scripting.Dictionary') + dict.add("foo", "FOO") + dict["foo"] = "BAR" + assert_equal("BAR", dict["foo"]) + end end end