Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8289431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:30:23+00:00 2026-06-08T12:30:23+00:00

In Ruby, what’s the best way to determine if an object belongs to a

  • 0

In Ruby, what’s the best way to determine if an object belongs to a user-defined, gem-defined, or standard-library-defined class, as opposed to a class in the Core library (such as Object, String, Hash, Numeric, etc.)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:30:24+00:00Added an answer on June 8, 2026 at 12:30 pm

    Predefined List

    # Put your own list of classes here...
    NATIVES = [ Object, String, Hash, Numeric ]
    
    do_something if NATIVES.include?( my_object.class )
    

    Snapshotted Classes

    # Before the user can load their own classes, find all existing classes
    BUILTINS = ObjectSpace.each_object.select{ |o| o.class==Class }
    
    do_something if BUILTINS.include?( my_object.class )
    

    Here’s the list of objects I get snapshotted in my interpreter:

    ARGF.class
    ArgumentError
    Array
    BasicObject
    Bignum
    Binding
    Class
    Complex
    Data
    Dir
    EOFError
    Encoding
    Encoding::CompatibilityError
    Encoding::Converter
    Encoding::ConverterNotFoundError
    Encoding::InvalidByteSequenceError
    Encoding::UndefinedConversionError
    EncodingError
    Enumerator
    Enumerator::Generator
    Enumerator::Yielder
    Errno::E2BIG
    Errno::EACCES
    Errno::EADDRINUSE
    Errno::EADDRNOTAVAIL
    Errno::EAFNOSUPPORT
    Errno::EAGAIN
    Errno::EALREADY
    Errno::EBADF
    Errno::EBUSY
    Errno::ECHILD
    Errno::ECONNABORTED
    Errno::ECONNREFUSED
    Errno::ECONNRESET
    Errno::EDEADLK
    Errno::EDESTADDRREQ
    Errno::EDOM
    Errno::EDQUOT
    Errno::EEXIST
    Errno::EFAULT
    Errno::EFBIG
    Errno::EHOSTDOWN
    Errno::EHOSTUNREACH
    Errno::EILSEQ
    Errno::EINPROGRESS
    Errno::EINTR
    Errno::EINVAL
    Errno::EIO
    Errno::EISCONN
    Errno::EISDIR
    Errno::ELOOP
    Errno::EMFILE
    Errno::EMLINK
    Errno::EMSGSIZE
    Errno::ENAMETOOLONG
    Errno::ENETDOWN
    Errno::ENETRESET
    Errno::ENETUNREACH
    Errno::ENFILE
    Errno::ENOBUFS
    Errno::ENODEV
    Errno::ENOENT
    Errno::ENOEXEC
    Errno::ENOLCK
    Errno::ENOMEM
    Errno::ENOPROTOOPT
    Errno::ENOSPC
    Errno::ENOSYS
    Errno::ENOTCONN
    Errno::ENOTDIR
    Errno::ENOTEMPTY
    Errno::ENOTSOCK
    Errno::ENOTTY
    Errno::ENXIO
    Errno::EOPNOTSUPP
    Errno::EPERM
    Errno::EPFNOSUPPORT
    Errno::EPIPE
    Errno::EPROCLIM
    Errno::EPROTONOSUPPORT
    Errno::EPROTOTYPE
    Errno::ERANGE
    Errno::EREMOTE
    Errno::EROFS
    Errno::ESHUTDOWN
    Errno::ESOCKTNOSUPPORT
    Errno::ESPIPE
    Errno::ESRCH
    Errno::ESTALE
    Errno::ETIMEDOUT
    Errno::ETOOMANYREFS
    Errno::EUSERS
    Errno::EWOULDBLOCK
    Errno::EXDEV
    Errno::NOERROR
    Exception
    FalseClass
    Fiber
    FiberError
    File
    File::Stat
    Fixnum
    Float
    FloatDomainError
    Gem::CommandLineError
    Gem::DependencyError
    Gem::DependencyRemovalException
    Gem::DocumentError
    Gem::EndOfYAMLException
    Gem::Exception
    Gem::FilePermissionError
    Gem::FormatException
    Gem::GemNotFoundException
    Gem::GemNotInHomeException
    Gem::InstallError
    Gem::InvalidSpecificationException
    Gem::LoadError
    Gem::OperationNotSupportedError
    Gem::RemoteError
    Gem::RemoteInstallationCancelled
    Gem::RemoteInstallationSkipped
    Gem::RemoteSourceException
    Gem::SystemExitException
    Gem::VerificationError
    Hash
    IO
    IOError
    IndexError
    Integer
    Interrupt
    KeyError
    LoadError
    LocalJumpError
    MatchData
    Math::DomainError
    Method
    Module
    Mutex
    NameError
    NameError::message
    NilClass
    NoMemoryError
    NoMethodError
    NotImplementedError
    Numeric
    Object
    Proc
    Process::Status
    Random
    Range
    RangeError
    Rational
    Regexp
    RegexpError
    RubyVM
    RubyVM::Env
    RubyVM::InstructionSequence
    RuntimeError
    ScriptError
    SecurityError
    SignalException
    StandardError
    StopIteration
    String
    Struct
    Struct::Tms
    Symbol
    SyntaxError
    SystemCallError
    SystemExit
    SystemStackError
    Thread
    ThreadError
    ThreadGroup
    Time
    TrueClass
    TypeError
    UnboundMethod
    ZeroDivisionError
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!ruby class Car < ActiveRecord::Base belongs_to :user end @cars = Car.where(:user_id => current_user.id).limit(10) I
Ruby can add methods to the Number class and other core types to get
Ruby's unit testing framework executes unit tests even though nobody creates unit test object.
Ruby defines #clone in Object . To my suprise, some classes raise Exceptions when
Ruby Version: 1.8 Rails Version: 2.3 I have a class in which I have
ruby 1.9.2p290 rails 3.1.1 Basically I have two models: CHEFS and RECIPES. class Chef
Ruby is fully object oriented language . In ruby, everything is an object &
Ruby has two ways of referring to the standard input: The STDIN constant ,
ruby-1.9.2-p180 :007 > Factory.define :user do |user| ruby-1.9.2-p180 :008 > user.email user@example.com ruby-1.9.2-p180 :009?>
ruby version is 1.9.2p290 I am using the following gemset D:\work\software\mongoid>gem list * LOCAL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.