Returns the list of public methods accessible to obj. If the all parameter is set to false
, only those methods in the receiver will be listed.
Similar to method, searches public method only.
Processes a string returned by message
.
It may add the class name of the exception to the end of the first line. Also, when highlight
keyword is true, it adds ANSI escape sequences to make the message bold.
If you override this method, it must be tolerant for unknown keyword arguments. All keyword arguments passed to full_message
are delegated to this method.
This method is overridden by did_you_mean and error_highlight to add their information.
A user-defined exception class can also define their own detailed_message
method to add supplemental information. When highlight
is true, it can return a string containing escape sequences, but use widely-supported ones. It is recommended to limit the following codes:
Reset (\e[0m
)
Bold (\e[1m
)
Underline (\e[4m
)
Foreground color except white and black
Red (\e[31m
)
Green (\e[32m
)
Yellow (\e[33m
)
Blue (\e[34m
)
Magenta (\e[35m
)
Cyan (\e[36m
)
Use escape sequences carefully even if highlight
is true. Do not use escape sequences to express essential information; the message should be readable even if all escape sequences are ignored.
Return a list of the local variable names defined where this NameError
exception was raised.
Internal use only.
Returns the number of digits a Float
object is allowed to have; the result is system-dependent:
BigDecimal.double_fig # => 16
Synonym for ENV
.
Returns true
if the given year is a leap year in the proleptic Gregorian calendar, false
otherwise:
Date.gregorian_leap?(2000) # => true Date.gregorian_leap?(2001) # => false
Related: Date.julian_leap?
.
Waits until IO
is readable and returns a truthy value, or a falsy value when times out. Returns a truthy value immediately when buffered data is available.
You must require ‘io/wait’ to use this method.
Waits until IO
is writable and returns a truthy value or a falsy value when times out.
You must require ‘io/wait’ to use this method.
Calls the given block with each codepoint in the stream; returns self
:
f = File.new('t.rus') a = [] f.each_codepoint {|c| a << c } a # => [1090, 1077, 1089, 1090] f.close
Returns an Enumerator
if no block is given.
Related: IO#each_byte
, IO#each_char
.
Removes the named field from the object and returns the value the field contained if it was defined. You may optionally provide a block. If the field is not defined, the result of the block is returned, or a NameError
is raised if no block was given.
require "ostruct" person = OpenStruct.new(name: "John", age: 70, pension: 300) person.delete_field!("age") # => 70 person # => #<OpenStruct name="John", pension=300>
Setting the value to nil
will not remove the attribute:
person.pension = nil person # => #<OpenStruct name="John", pension=nil> person.delete_field('number') # => NameError person.delete_field('number') { 8675_309 } # => 8675309
Deletes every element of the set for which block evaluates to true, and returns self. Returns an enumerator if no block is given.
Iterates over each component of the path.
Pathname.new("/usr/bin/ruby").each_filename {|filename| ... } # yields "usr", "bin", and "ruby".
Returns an Enumerator
if no block was given.
enum = Pathname.new("/usr/bin/ruby").each_filename # ... do stuff ... enum.each { |e| ... } # yields "usr", "bin", and "ruby".
This method is called when the parser found syntax error.
Returns an Addrinfo
object for remote address obtained by getpeername.
Note that addrinfo.protocol is filled by 0.
TCPSocket.open("www.ruby-lang.org", 80) {|s| p s.remote_address #=> #<Addrinfo: 221.186.184.68:80 TCP> } TCPServer.open("127.0.0.1", 1728) {|serv| c = TCPSocket.new("127.0.0.1", 1728) s = serv.accept p s.remote_address #=> #<Addrinfo: 127.0.0.1:36504 TCP> }
With a block given, calls the block with each remaining codepoint in the stream; see Codepoint IO.
With no block given, returns an enumerator.
Invokes Release method of Dispatch interface of WIN32OLE
object. You should not use this method because this method exists only for debugging WIN32OLE
. The return value is reference counter of OLE object.
invokes Release method of Dispatch interface of WIN32OLE
object. Usually, you do not need to call this method because Release method called automatically when WIN32OLE
object garbaged.