An IO
over a file descriptor.
Returns true
if this IO
is closed.
Enables character processing for the duration of the given block.
Enables character processing for this IO.
The raw file-descriptor.
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
Turns off character echoing for the duration of the given block.
Turns off character echoing for this IO.
Returns the current position (in bytes) in this IO
.
Sets the current position (in bytes) in this IO
.
Enables raw mode for the duration of the given block.
Enables raw mode for this IO.
Seeks to a given offset (in bytes) according to the whence argument.
Same as #seek
but yields to the block after seeking and eventually seeks back to the original position when the block returns.
Returns true
if this IO
is associated with a terminal device (tty), false
otherwise.
IO::Buffered
Crystal::System::FileDescriptor
Crystal::System::FileDescriptor
IO::Evented
IO
IO
Reference
Reference
Object
Object
Enables character processing for the duration of the given block. The so called cooked mode is the standard behavior of a terminal, doing line wise editing by the terminal and only sending the input to the program on a newline. Only call this when this IO is a TTY, such as a not redirected stdin.
Enables character processing for this IO. The so called cooked mode is the standard behavior of a terminal, doing line wise editing by the terminal and only sending the input to the program on a newline. Only call this when this IO is a TTY, such as a not redirected stdin.
The raw file-descriptor. It is defined to be an Int
, but its size is platform-specific.
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person def initialize(@name : String, @age : Int32) end end Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
Turns off character echoing for the duration of the given block. This will prevent displaying back to the user what they enter on the terminal. Only call this when this IO is a TTY, such as a not redirected stdin.
print "Enter password: " password = STDIN.noecho &.gets.try &.chomp puts
Turns off character echoing for this IO. This will prevent displaying back to the user what they enter on the terminal. Only call this when this IO is a TTY, such as a not redirected stdin.
Returns the current position (in bytes) in this IO
.
File.write("testfile", "hello") file = File.new("testfile") file.pos # => 0 file.gets(2) # => "he" file.pos # => 2
Sets the current position (in bytes) in this IO
.
File.write("testfile", "hello") file = File.new("testfile") file.pos = 3 file.gets_to_end # => "lo"
Enables raw mode for the duration of the given block. In raw mode every keypress is directly sent to the program, no interpretation is done by the terminal. Only call this when this IO is a TTY, such as a not redirected stdin.
Enables raw mode for this IO. In raw mode every keypress is directly sent to the program, no interpretation is done by the terminal. Only call this when this IO is a TTY, such as a not redirected stdin.
Seeks to a given offset (in bytes) according to the whence argument. Returns self
.
File.write("testfile", "abc") file = File.new("testfile") file.gets(3) # => "abc" file.seek(1, IO::Seek::Set) file.gets(2) # => "bc" file.seek(-1, IO::Seek::Current) file.gets(1) # => "c"
Same as #seek
but yields to the block after seeking and eventually seeks back to the original position when the block returns.
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/IO/FileDescriptor.html