returns the indexth byte as an integer.
modifies the indexth byte as integer.
Gets the next 8-bit byte (0..255) from ios. Returns nil
if called at end of file.
f = File.new("testfile") f.getbyte #=> 84 f.getbyte #=> 104
Reads a byte as with IO#getbyte
, but raises an EOFError
on end of file.
Pushes back bytes (passed as a parameter) onto ios, such that a subsequent buffered read will return it. Only one byte may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several bytes that have been pushed back). Has no effect with unbuffered reads (such as IO#sysread
).
f = File.new("testfile") #=> #<File:testfile> b = f.getbyte #=> 0x38 f.ungetbyte(b) #=> nil f.getbyte #=> 0x38
Obtains the host information for hostname.
p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"]
Obtains the host information for address.
p Socket.gethostbyaddr([221,186,184,68].pack("CCCC")) #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"]
Obtains the port number for service_name.
If protocol_name is not given, “tcp” is assumed.
Socket.getservbyname("smtp") #=> 25 Socket.getservbyname("shell") #=> 514 Socket.getservbyname("syslog", "udp") #=> 514
Obtains the port number for port.
If protocol_name is not given, “tcp” is assumed.
Socket.getservbyport(80) #=> "www" Socket.getservbyport(514, "tcp") #=> "shell" Socket.getservbyport(514, "udp") #=> "syslog"
Lookups host information by hostname.
TCPSocket.gethostbyname("localhost") #=> ["localhost", ["hal"], 2, "127.0.0.1"]
Gets the next 8-bit byte (0..255) from ARGF
. Returns nil
if called at the end of the stream.
For example:
$ echo "foo" > file $ ruby argf.rb file ARGF.getbyte #=> 102 ARGF.getbyte #=> 111 ARGF.getbyte #=> 111 ARGF.getbyte #=> 10 ARGF.getbyte #=> nil
Reads the next 8-bit byte from ARGF
and returns it as an Integer
. Raises an EOFError
after the last byte of the last file has been read.
For example:
$ echo "foo" > file $ ruby argf.rb file ARGF.readbyte #=> 102 ARGF.readbyte #=> 111 ARGF.readbyte #=> 111 ARGF.readbyte #=> 10 ARGF.readbyte #=> end of file reached (EOFError)
Returns the version of libyaml being used
The path to the running Ruby interpreter.
Returns a String containing the API compatibility version of Ruby
Returns the latest release version of RubyGems.
A Gem::Version
for the currently running Ruby.
A Gem::Version
for the currently running RubyGems
Paths where RubyGems’ .rb files and bin files are installed
A wrapper around RUBY_ENGINE const that may not be defined
Allows setting path to Ruby. This method is available when requiring ‘rubygems/test_case’