#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    4
    Rep Power
    0

    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. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    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,
    Originally Posted by Pickaxe
    The time library adds functionality to the built-in class Time, supporting date and/or time formats used by RFC 2882 (e-mail), RFC 2616 (HTTP), and ISO 8601 (the subset used by XML schema)
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    4
    Rep Power
    0
    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')
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    Originally Posted by drhenner
    so it's not wise to go through every file and (require 'time')
    Unless, of course, each of those files requires the time library...
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    4
    Rep Power
    0
    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
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    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.
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    4
    Rep Power
    0
    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
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    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
    Notice the differences.
    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.
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog

IMN logo majestic logo threadwatch logo seochat tools logo