Forces the fiber to be blocking for the duration of the block. Returns the result of the block.
See the “Non-blocking fibers” section in class docs for details.
Returns true
if fiber
is blocking and false
otherwise. Fiber
is non-blocking if it was created via passing blocking: false
to Fiber.new
, or via Fiber.schedule
.
Note that, even if the method returns false
, the fiber behaves differently only if Fiber.scheduler
is set in the current thread.
See the “Non-blocking fibers” section in class docs for details.
Returns false
if the current fiber is non-blocking. Fiber
is non-blocking if it was created via passing blocking: false
to Fiber.new
, or via Fiber.schedule
.
If the current Fiber
is blocking, the method returns 1. Future developments may allow for situations where larger integers could be returned.
Note that, even if the method returns false
, Fiber
behaves differently only if Fiber.scheduler
is set in the current thread.
See the “Non-blocking fibers” section in class docs for details.
Sets the position in self
to zero; see Dir As Stream-Like:
dir = Dir.new('example') dir.read # => "." dir.read # => ".." dir.pos # => 2 dir.rewind # => #<Dir:example> dir.pos # => 0
Removes the directory at dirpath
from the underlying file system:
Dir.rmdir('foo') # => 0
Raises an exception if the directory is not empty.
Creates a new name for an existing file using a hard link. Will not overwrite new_name if it already exists (raising a subclass of SystemCallError
). Not available on all platforms.
File.link("testfile", ".testfile") #=> 0 IO.readlines(".testfile")[0] #=> "This is line one\n"
Creates a symbolic link called new_name for the existing file old_name. Raises a NotImplemented exception on platforms that do not support symbolic links.
File.symlink("testfile", "link2test") #=> 0
Returns the name of the file referenced by the given link. Not available on all platforms.
File.symlink("testfile", "link2test") #=> 0 File.readlink("link2test") #=> "testfile"
Deletes the named files, returning the number of names passed as arguments. Raises an exception on any error. Since the underlying implementation relies on the unlink(2)
system call, the type of exception raised depends on its error type (see linux.die.net/man/2/unlink) and has the form of e.g. Errno::ENOENT.
See also Dir::rmdir
.
Returns the current umask value for this process. If the optional argument is given, set the umask to that value and return the previous value. Umask values are subtracted from the default permissions, so a umask of 0222
would make a file read-only for everyone.
File.umask(0006) #=> 18 File.umask #=> 6
Returns a new string formed by joining the strings using "/"
.
File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
Returns true
if filepath
points to a symbolic link, false
otherwise:
symlink = File.symlink('t.txt', 'symlink') File.symlink?('symlink') # => true File.symlink?('t.txt') # => false
Returns a string which represents the encoding for programmers.
Encoding::UTF_8.inspect #=> "#<Encoding:UTF-8>" Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
Search the encoding with specified name. name should be a string.
Encoding.find("US-ASCII") #=> #<Encoding:US-ASCII>
Names which this method accept are encoding names and aliases including following special aliases
default external encoding
default internal encoding
locale encoding
filesystem encoding
An ArgumentError
is raised when no encoding with name. Only Encoding.find("internal")
however returns nil when no encoding named “internal”, in other words, when Ruby has no default internal encoding.
Rewinds the enumeration sequence to the beginning.
If the enclosed object responds to a “rewind” method, it is called.
Creates a printable version of e.
Returns a string containing a human-readable representation of obj. The default inspect
shows the object’s class name, an encoding of its memory address, and a list of the instance variables and their values (by calling inspect
on each of them). User defined classes should override this method to provide a better representation of obj. When overriding this method, it should return a string whose encoding is compatible with the default external encoding.
[ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "2008-03-08 19:43:39 +0900" class Foo end Foo.new.inspect #=> "#<Foo:0x0300c868>" class Bar def initialize @bar = 1 end end Bar.new.inspect #=> "#<Bar:0x0300c868 @bar=1>"
Return this exception’s class name and message.
Return the matchee associated with this NoMatchingPatternKeyError
exception.
Invokes Module.append_features
on each parameter in reverse order.
Import class refinements from module into the current class or module definition.