Re: Issue related to class initialization and irb
- From: darren kirby <bulliver@xxxxxxxxxxxxxxx>
- Date: Sat, 30 Jun 2007 06:20:02 +0900
quoth the Chris Shea:
On Jun 29, 11:17 am, darren kirby <bulli...@xxxxxxxxxxxxxxx> wrote:
This is a follow-up question for me as well. Even when the object_id
value is represented in hex it does not match the default output. I guess
the default value is the object's address in memory or somesuch?
The hex value is double the object_id. So in my example, redefining
inspect as
"#<Test:0x#{(self.object_id*2).to_s(16)}>"
would give you what you're expecting.
Chris
Thanks again Chris.
I still have one more issue here. My knowledge of access control is admittedly
superficial, but since 'inspect' is called internally I should be able to
define it as a private method shouldn't I? Or is it bombing because it is
called from irb?
When I define it privately I get:
-----------------------
irb(main):016:0> song = FlacInfo.new("test.flac")
NoMethodError: private method `inspect' called for #<FlacInfo:0x6f919ec4>
from /usr/lib/ruby/1.8/irb.rb:298:in `output_value'
from /usr/lib/ruby/1.8/irb.rb:151:in `eval_input'
from /usr/lib/ruby/1.8/irb.rb:259:in `signal_status'
from /usr/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:244:in
`each_top_level_statement'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in `loop'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in
`each_top_level_statement'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in `catch'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in
`each_top_level_statement'
from /usr/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /usr/lib/ruby/1.8/irb.rb:70:in `start'
from /usr/lib/ruby/1.8/irb.rb:69:in `catch'
from /usr/lib/ruby/1.8/irb.rb:69:in `start'
from /usr/bin/irb:13
Maybe IRB bug!!
-------------------------
Is this really a bug or is it just a necessary product of calling from irb?
I don't really need or want this as a public method. I suppose I could just
make it so Rdoc doesn't document it, as it isn't like it is going to hurt
anything if called directly.
-d
--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
.
- References:
- Issue related to class initialization and irb
- From: darren kirby
- Re: Issue related to class initialization and irb
- From: darren kirby
- Re: Issue related to class initialization and irb
- From: Chris Shea
- Issue related to class initialization and irb
- Prev by Date: Re: newby non/programmer trying to understand classes
- Next by Date: Weird deadlock problems with Slave/drb
- Previous by thread: Re: Issue related to class initialization and irb
- Next by thread: Re: Issue related to class initialization and irb
- Index(es):
Relevant Pages
|