|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
What file does the Class belong
OK I am running fedora 9 and ruby 1.8.6. I run the following command (Time.methods) and only 1/2 of the methods I expect are included. When I look at the Time class I se all the methods. I assume I am clashing with another Class called Time but I don't see it. If i put (require 'time') I see all the methods.
I just want to know where the files is that created the object with 1/2 the methods. what is the best way to solve this? |
|
#2
|
|||
|
|||
|
Code:
irb(main):001:0> Time.methods.size => 83 irb(main):002:0> require 'time' => true irb(main):003:0> Time.methods.size => 90 I'm not sure 7 extra methods constitutes half... Also, so you know, Quote:
__________________
-- I'll provide you with reference points; if they dont work, refer to something else. If you process text, this might make your life a little easier. |
|
#3
|
|||
|
|||
|
sorry about saying 1/2... but I still have a question...
I just want to know where the files is that created the object with 1/2 the methods. what is the best way to solve this? basically mongrel uses the method httpdate. this method was working before I upgraded fedora and now i mongrel gives me a NO method error. My app uses httpdate too so it's not wise to go through every file and (require 'time') |
|
#4
|
|||
|
|||
|
Quote:
|
|
#5
|
|||
|
|||
|
well i found the bug.
the files (Mongrel) were already requiring time... someone added a time class to my rails app in subversion and mongrel got all messed up. still would like to know how to get the file that a Class exist's in with ruby code. I did a grep for "class Time" but that wasn't ruby was it. Anyone know my original question please answer. Thank you |
|
#6
|
|||
|
|||
|
I'm not sure I understand you completely.
Let me explain what I think I know before I give my answer: You are looking for the source code used to build the Time object. You are also looking for the source code used to build the extended library Time object. To answer those two, you will need to have access to the source tree you compiled when you installed ruby. From my source tree it looks something like: Code:
ruby-1.8.6/time.c (the standard time class) ruby-1.8.6/lib/time.rb (the extended interface to that class) Although I can not seem to understand why you would need access to those files (specifically the C files). If you changed them, you would not affect the binaries that are currently being run. If you changed them with the intent of rebuilding the binaries you would have to know a lot more that it appears that you know now. Also, if you did actually change things, it would only be good on your personal system since other will have the regular version on their system. You can find all the documentation on a class either online or in a book, why is it you are looking through these files? (Sorry to belabor the point here...) The library file is written in ruby, but the same caveat applies about changing that file and trying to deploy. Hope that helps. |
|
#7
|
|||
|
|||
|
I wanted to see the files just out of curiousity. actually I was really thinking of any Class created not just Time.
Lets say I have a rails app and I created 2 Class's with the name "Jasper". If there were a name collision I'd like to find the Class that a specific object was created from. No I would never mess with ruby's source code. If I did recompiling the source would be pretty easy though. Thanks for the reply |
|
#8
|
|||
|
|||
|
You can easily see what is loaded at any point.
Examine the following example Code:
irb(main):001:0> $".each { |x| puts x }
e2mmap.rb
irb/init.rb
irb/workspace.rb
irb/context.rb
irb/extend-command.rb
irb/output-method.rb
irb/notifier.rb
...
irb/locale.rb
irb.rb
irb(main):002:0> require 'time'
=> true
irb(main):003:0> $".each { |x| puts x }
e2mmap.rb
irb/init.rb
irb/workspace.rb
irb/context.rb
irb/extend-command.rb
irb/output-method.rb
irb/notifier.rb
...
irb/locale.rb
irb.rb
rational.rb
date/format.rb
parsedate.rb
time.rb
Above, I use teh variable $" to get at those values. However, that does not tell you where they may be loaded from. In order to determine that, you would have to use $:. Hope that helps. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Ruby Programming > What file does the Class belong |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|