See File.lstat
.
Checks the status of the child process specified by pid
. Returns nil
if the process is still alive.
If the process is not alive, and raise
was true, a PTY::ChildExited
exception will be raised. Otherwise it will return a Process::Status
instance.
pid
The process id of the process to check
raise
If true
and the process identified by pid
is no longer alive a PTY::ChildExited
is raised.
creates a new socket object connected to host:port using TCP/IP.
If local_host:local_port is given, the socket is bound to it.
The optional last argument opts is options represented by a hash. opts may have following options:
specify the timeout in seconds.
If a block is given, the block is called with the socket. The value of the block is returned. The socket is closed when this method returns.
If no block is given, the socket is returned.
Socket.tcp("www.ruby-lang.org", 80) {|sock| sock.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" sock.close_write puts sock.read }
iterates over the list of Addrinfo
objects obtained by Addrinfo.getaddrinfo
.
Addrinfo.foreach(nil, 80) {|x| p x } #=> #<Addrinfo: 127.0.0.1:80 TCP (:80)> # #<Addrinfo: 127.0.0.1:80 UDP (:80)> # #<Addrinfo: [::1]:80 TCP (:80)> # #<Addrinfo: [::1]:80 UDP (:80)>
returns an addrinfo object for TCP address.
Addrinfo.tcp("localhost", "smtp") #=> #<Addrinfo: 127.0.0.1:25 TCP (localhost:smtp)>
Returns the path of the local address of unixsocket.
s = UNIXServer.new("/tmp/sock") p s.path #=> "/tmp/sock"
Calls the block with each remaining line read from the stream; does nothing if already at end-of-file; returns self
. See Line IO.
Reads and returns the next character from the stream; see Character IO.
Pushes back (“unshifts”) a character or integer onto the stream; see Character IO.
See IO#putc
.
Returns false
. Just for compatibility to IO
.
Truncates the buffer string to at most integer bytes. The stream must be opened for writing.
Appends the given more_string
to the [stored string].
Returns self
.
Does not affect the [positions] or [match values].
scanner = StringScanner.new('foo') scanner.string # => "foo" scanner.terminate scanner.concat('barbaz') # => #<StringScanner 3/9 "foo" @ "barba..."> scanner.string # => "foobarbaz" put_situation(scanner) # Situation: # pos: 3 # charpos: 3 # rest: "barbaz" # rest_size: 6
Attempts to [match] the given pattern
at the beginning of the [target substring]; does not modify the [positions].
If the match succeeds:
Returns the matched substring.
Sets all [match values].
scanner = StringScanner.new('foobarbaz') scanner.pos = 3 scanner.check('bar') # => "bar" put_match_values(scanner) # Basic match values: # matched?: true # matched_size: 3 # pre_match: "foo" # matched : "bar" # post_match: "baz" # Captured match values: # size: 1 # captures: [] # named_captures: {} # values_at: ["bar", nil] # []: # [0]: "bar" # [1]: nil # => 0..1 put_situation(scanner) # Situation: # pos: 3 # charpos: 3 # rest: "barbaz" # rest_size: 6
If the match fails:
Returns nil
.
Clears all [match values].
scanner.check(/nope/) # => nil match_values_cleared?(scanner) # => true
Iterates over each item of OLE collection which has IEnumVARIANT interface.
excel = WIN32OLE.new('Excel.Application') book = excel.workbooks.add sheets = book.worksheets(1) cells = sheets.cells("A1:A5") cells.each do |cell| cell.value = 10 end
Calls the given block with each key-value pair; returns self
:
h = {foo: 0, bar: 1, baz: 2} h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}
Output:
foo: 0 bar: 1 baz: 2
Returns a new Enumerator
if no block given:
h = {foo: 0, bar: 1, baz: 2} e = h.each_pair # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_pair> h1 = e.each {|key, value| puts "#{key}: #{value}"} h1 # => {:foo=>0, :bar=>1, :baz=>2}
Output:
foo: 0 bar: 1 baz: 2