I hacked the to_hash object for Object (I'm not saying this is a good idea, just an experiment). When I ran into an odd issue where IO stopped working.
#lib/object.rb class Object def to_hash self.instance_variables.inject({}) { |hash,var| hash[var.to_s.delete("@")] = self.instance_variable_get(var); hash } end end
in run_test1 I get
<internal:lib/rubygems/custom_require>:29:in `set_encoding': wrong number of arguments (0 for 1..2) (ArgumentError) from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' from .../run_test1.rb:2:in `<main>'
in run_test2 I get
run_test2.rb:3:in `initialize': No such file or directory - test.txt (Errno::ENOENT from run_test2.rb:3:in `open' from run_test2.rb:3:in `<main>'
(if the file exists, it says the file is not open for writing)
Until I'm surprised this happened - just curious what is going on here? Theoretically, this should be good, but what is the main reason.
Relevant Information:
- ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
- XP SP3 32-bit
- VERSION OF ABROADS: 1.8.12
source share