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.
Calls WIN32OLE#invoke
method.
Returns WIN32OLE::Type
object.
excel = WIN32OLE.new('Excel.Application') tobj = excel.ole_type
Returns the WIN32OLE::TypeLib
object. The object represents the type library which contains the WIN32OLE
object.
excel = WIN32OLE.new('Excel.Application') tlib = excel.ole_typelib puts tlib.name # -> 'Microsoft Excel 9.0 Object Library'
Invoked by Ruby when obj is sent a message it cannot handle. symbol is the symbol for the method called, and args are any arguments that were passed to it. By default, the interpreter raises an error when this method is called. However, it is possible to override the method to provide more dynamic behavior. If it is decided that a particular method should not be handled, then super should be called, so that ancestors can pick up the missing method. The example below creates a class Roman
, which responds to methods with names consisting of roman numerals, returning the corresponding integer values.
class Roman def roman_to_int(str) # ... end def method_missing(symbol, *args) str = symbol.id2name begin roman_to_int(str) rescue super(symbol, *args) end end end r = Roman.new r.iv #=> 4 r.xxiii #=> 23 r.mm #=> 2000 r.foo #=> NoMethodError
Returns the default proc for self
(see Default Values):
h = {} h.default_proc # => nil h.default_proc = proc {|hash, key| "Default value for #{key}" } h.default_proc.class # => Proc
Sets the default proc for self
to proc
(see Default Values):
h = {} h.default_proc # => nil h.default_proc = proc { |hash, key| "Default value for #{key}" } h.default_proc.class # => Proc h.default_proc = nil h.default_proc # => nil
If a block given, calls the block with each key-value pair; deletes each entry for which the block returns a truthy value; returns self
:
h = {foo: 0, bar: 1, baz: 2} h.delete_if {|key, value| value > 0 } # => {:foo=>0}
If no block given, returns a new Enumerator:
h = {foo: 0, bar: 1, baz: 2} e = h.delete_if # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:delete_if> e.each { |key, value| value > 0 } # => {:foo=>0}
Yields each environment variable name and its value as a 2-element Array
, deleting each environment variable for which the block returns a truthy value, and returning ENV
(regardless of whether any deletions):
ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2') ENV.delete_if { |name, value| name.start_with?('b') } # => ENV ENV # => {"foo"=>"0"} ENV.delete_if { |name, value| name.start_with?('b') } # => ENV
Returns an Enumerator
if no block given:
ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2') e = ENV.delete_if # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:delete_if!> e.each { |name, value| name.start_with?('b') } # => ENV ENV # => {"foo"=>"0"} e.each { |name, value| name.start_with?('b') } # => ENV
Iterates over each codepoint of each file in ARGF
.
This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last codepoint of the first file has been returned, the first codepoint of the second file is returned. The ARGF.filename
method can be used to determine the name of the file in which the current codepoint appears.
If no block is given, an enumerator is returned instead.
Returns the methods available to this delegate object as the union of this object’s and _getobj_ public methods.
Serialization support for the object returned by _getobj_.
Creates a new compiler for ERB
. See ERB::Compiler.new for details
Returns a new binding each time near TOPLEVEL_BINDING for runs that do not specify a binding.