Define methodname as instance method of mod from compiled Ruby source.
example:
filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml erb = ERB.new(File.read(filename)) erb.def_method(MyClass, 'render(arg1, arg2)', filename) print MyClass.new.render('foo', 123)
Returns true if the ipaddr is an IPv4-compatible IPv6 address.
Returns a new ipaddr built by converting the native IPv4 address into an IPv4-compatible IPv6 address.
Returns additional info.
Returns a Method
of superclass which would be called when super is used or nil if there is no method on superclass.
Returns a Method
of superclass which would be called when super is used or nil if there is no method on superclass.
Return the name at the definition of the method being called
Returns garbage collector generation for the given object
.
class B include ObjectSpace def foo trace_object_allocations do obj = Object.new p "Generation is #{allocation_generation(obj)}" end end end B.new.foo #=> "Generation is 3"
See ::trace_object_allocations
for more information and examples.
Parse a YAML string in yaml
. Returns the Psych::Nodes::Stream
. This method can handle multiple YAML documents contained in yaml
. filename
is used in the exception message if a Psych::SyntaxError
is raised.
If a block is given, a Psych::Nodes::Document
node will be yielded to the block as it’s being parsed.
Raises a Psych::SyntaxError
when a YAML syntax error is detected.
Example:
Psych.parse_stream("---\n - a\n - b") # => #<Psych::Nodes::Stream:0x00> Psych.parse_stream("--- a\n--- b") do |node| node # => #<Psych::Nodes::Document:0x00> end begin Psych.parse_stream("--- `", filename: "file.txt") rescue Psych::SyntaxError => ex ex.file # => 'file.txt' ex.message # => "(file.txt): found character that cannot start any token" end
Raises a TypeError
when NilClass
is passed.
See Psych::Nodes
for more information about YAML AST.
Glob pattern for require-able path suffixes.
Returns true if the contents of a stream a
and b
are identical.
Returns true if the contents of a stream a
and b
are identical.
Returns an Array
of methods names which have the option opt
.
p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
Returns whether or not the given framework
can be found on your system. If found, a macro is passed as a preprocessor constant to the compiler using the framework name, in uppercase, prepended with HAVE_FRAMEWORK_
.
For example, if have_framework('Ruby')
returned true, then the HAVE_FRAMEWORK_RUBY
preprocessor macro would be passed to the compiler.
If fw
is a pair of the framework name and its header file name that header file is checked, instead of the normally used header file which is named same as the framework.
Indicated whether this Cipher
instance uses an Authenticated Encryption mode.
returns the timestamp as a time object.
ancillarydata should be one of following type:
SOL_SOCKET/SCM_TIMESTAMP (microsecond) GNU/Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOS X
SOL_SOCKET/SCM_TIMESTAMPNS (nanosecond) GNU/Linux
SOL_SOCKET/SCM_BINTIME (2**(-64) second) FreeBSD
Addrinfo.udp
(“127.0.0.1”, 0).bind {|s1|
Addrinfo.udp("127.0.0.1", 0).bind {|s2| s1.setsockopt(:SOCKET, :TIMESTAMP, true) s2.send "a", 0, s1.local_address ctl = s1.recvmsg.last p ctl #=> #<Socket::AncillaryData: INET SOCKET TIMESTAMP 2009-02-24 17:35:46.775581> t = ctl.timestamp p t #=> 2009-02-24 17:35:46 +0900 p t.usec #=> 775581 p t.nsec #=> 775581000 }
}
Changes the parameters of the deflate stream to allow changes between different types of data that require different types of compression. Any unprocessed data is flushed before changing the params.
See Zlib::Deflate.new
for a description of level
and strategy
.
Returns the last access time for this file as an object of class Time
.
File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
Returns the birth time for stat.
If the platform doesn’t have birthtime, raises NotImplementedError
.
File.write("testfile", "foo") sleep 10 File.write("testfile", "bar") sleep 10 File.chmod(0644, "testfile") sleep 10 File.read("testfile") File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900 File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900 File.stat("testfile").ctime #=> 2014-02-24 11:19:37 +0900 File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900
Sends a PATCH request to the path
and gets a response, as an HTTPResponse
object.
Sends a PROPPATCH request to the path
and gets a response, as an HTTPResponse
object.
Sends an AUTHENTICATE command to authenticate the client. The auth_type
parameter is a string that represents the authentication mechanism to be used. Currently Net::IMAP
supports the authentication mechanisms:
LOGIN:: login using cleartext user and password. CRAM-MD5:: login with cleartext user and encrypted password (see [RFC-2195] for a full description). This mechanism requires that the server have the user's password stored in clear-text password.
For both of these mechanisms, there should be two args
: username and (cleartext) password. A server may not support one or the other of these mechanisms; check capability()
for a capability of the form “AUTH=LOGIN” or “AUTH=CRAM-MD5”.
Authentication is done using the appropriate authenticator object: see @@authenticators for more information on plugging in your own authenticator.
For example:
imap.authenticate('LOGIN', user, password)
A Net::IMAP::NoResponseError
is raised if authentication fails.