This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# Struct < Object --- # Includes: Enumerable (from ruby core) (from ruby core) --- Class Struct provides a convenient way to create a simple class that can store and fetch values. This example creates a subclass of `Struct`, `Struct::Customer`; the first argument, a string, is the name of the subclass; the other arguments, symbols, determine the *members* of the new subclass. Customer = Struct.new('Customer', :name, :address, :zip) Customer.name # => "Struct::Customer" Customer.class # => Class Customer.superclass # => Struct Corresponding to each member are two methods, a writer and a reader, that store and fetch values: methods = Customer.instance_methods false methods # => [:zip, :address=, :zip=, :address, :name, :name=] An instance of the subclass may be created, and its members assigned values, via method `::new`: joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe # => #<struct Struct::Customer name="Joe Smith", address="123 Maple, Anytown NC", zip=12345> The member values may be managed thus: joe.name # => "Joe Smith" joe.name = 'Joseph Smith' joe.name # => "Joseph Smith" And thus; note that member name may be expressed as either a string or a symbol: joe[:name] # => "Joseph Smith" joe[:name] = 'Joseph Smith, Jr.' joe['name'] # => "Joseph Smith, Jr." See Struct::new. ## What's Here First, what's elsewhere. Class Struct: * Inherits from [class Object](Object.html#class-Object-label-What-27s+Here). * Includes [module Enumerable](Enumerable.html#module-Enumerable-label-What-27s+Here), which provides dozens of additional methods. Here, class Struct provides methods that are useful for: * [Creating a Struct Subclass](#class-Struct-label-Methods+for+Creating+a+Struct+Subclass ) * [Querying](#class-Struct-label-Methods+for+Querying) * [Comparing](#class-Struct-label-Methods+for+Comparing) * [Fetching](#class-Struct-label-Methods+for+Fetching) * [Assigning](#class-Struct-label-Methods+for+Assigning) * [Iterating](#class-Struct-label-Methods+for+Iterating) * [Converting](#class-Struct-label-Methods+for+Converting) ### Methods for Creating a Struct Subclass ::new : Returns a new subclass of Struct. ### Methods for Querying #hash : Returns the integer hash code. #length, #size : Returns the number of members. ### Methods for Comparing [#==](#method-i-3D-3D) : Returns whether a given object is equal to `self`, using `==` to compare member values. #eql? : Returns whether a given object is equal to `self`, using `eql?` to compare member values. ### Methods for Fetching #[] : Returns the value associated with a given member name. #to_a, #values, #deconstruct : Returns the member values in `self` as an array. #deconstruct_keys : Returns a hash of the name/value pairs for given member names. #dig : Returns the object in nested objects that is specified by a given member name and additional arguments. #members : Returns an array of the member names. #select, #filter : Returns an array of member values from `self`, as selected by the given block. #values_at : Returns an array containing values for given member names. ### Methods for Assigning #[]= : Assigns a given value to a given member name. ### Methods for Iterating #each : Calls a given block with each member name. #each_pair : Calls a given block with each member name/value pair. ### Methods for Converting #inspect, #to_s : Returns a string representation of `self`. #to_h : Returns a hash of the member name/value pairs in `self`. --- # Constants: Group : Group Group is a Struct that is only available when compiled with `HAVE_GETGRENT`. The struct contains the following members: name : contains the name of the group as a String. passwd : contains the encrypted password as a String. An 'x' is returned if password access to the group is not available; an empty string is returned if no password is needed to obtain membership of the group. Must be compiled with `HAVE_STRUCT_GROUP_GR_PASSWD`. gid : contains the group's numeric ID as an integer. mem : is an Array of Strings containing the short login names of the members of the group. Passwd : Passwd Passwd is a Struct that contains the following members: name : contains the short login name of the user as a String. passwd : contains the encrypted password of the user as a String. an 'x' is returned if shadow passwords are in use. An '*' is returned if the user cannot log in using a password. uid : contains the integer user ID (uid) of the user. gid : contains the integer group ID (gid) of the user's primary group. dir : contains the path to the home directory of the user as a String. shell : contains the path to the login shell of the user as a String. ### The following members below are optional, and must be compiled with special flags: gecos : contains a longer String description of the user, such as a full name. Some Unix systems provide structured information in the gecos field, but this is system-dependent. must be compiled with `HAVE_STRUCT_PASSWD_PW_GECOS` change : password change time(integer) must be compiled with `HAVE_STRUCT_PASSWD_PW_CHANGE` quota : quota value(integer) must be compiled with `HAVE_STRUCT_PASSWD_PW_QUOTA` age : password age(integer) must be compiled with `HAVE_STRUCT_PASSWD_PW_AGE` class : user access class(string) must be compiled with `HAVE_STRUCT_PASSWD_PW_CLASS` comment : comment(string) must be compiled with `HAVE_STRUCT_PASSWD_PW_COMMENT` expire : account expiration time(integer) must be compiled with `HAVE_STRUCT_PASSWD_PW_EXPIRE` # Class methods: json_create keyword_init? members new # Instance methods: == [] []= as_json deconstruct deconstruct_keys dig each each_pair eql? filter hash inspect length members select size to_a to_h to_json to_s values values_at
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.