D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
gems
/
gems
/
rbs-3.8.0
/
stdlib
/
stringio
/
0
/
Filename :
stringio.rbs
back
Copy
# <!-- rdoc-file=ext/stringio/stringio.c --> # IO streams for strings, with access similar to [IO](rdoc-ref:IO); see # [IO](rdoc-ref:IO). # # ### About the Examples # # Examples on this page assume that StringIO has been required: # # require 'stringio' # class StringIO # <!-- # rdoc-file=ext/stringio/stringio.c # - StringIO.new(string = '', mode = 'r+') -> new_stringio # --> # Note that `mode` defaults to `'r'` if `string` is frozen. # # Returns a new StringIO instance formed from `string` and `mode`; see [Access # Modes](rdoc-ref:File@Access+Modes): # # strio = StringIO.new # => #<StringIO> # strio.close # # The instance should be closed when no longer needed. # # Related: StringIO.open (accepts block; closes automatically). # def initialize: (?String string, ?String? mode) -> void # <!-- # rdoc-file=ext/stringio/stringio.c # - StringIO.open(string = '', mode = 'r+') {|strio| ... } # --> # Note that `mode` defaults to `'r'` if `string` is frozen. # # Creates a new StringIO instance formed from `string` and `mode`; see [Access # Modes](rdoc-ref:File@Access+Modes). # # With no block, returns the new instance: # # strio = StringIO.open # => #<StringIO> # # With a block, calls the block with the new instance and returns the block's # value; closes the instance on block exit. # # StringIO.open {|strio| p strio } # # => #<StringIO> # # Related: StringIO.new. # def self.open: [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U def <<: (untyped arg0) -> self # <!-- # rdoc-file=ext/stringio/stringio.c # - binmode -> self # --> # Sets the data mode in `self` to binary mode; see [Data # Mode](rdoc-ref:File@Data+Mode). # def binmode: () -> self # <!-- # rdoc-file=ext/stringio/stringio.c # - close -> nil # --> # Closes `self` for both reading and writing. # # Raises IOError if reading or writing is attempted. # # Related: StringIO#close_read, StringIO#close_write. # def close: () -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - close_read -> nil # --> # Closes `self` for reading; closed-write setting remains unchanged. # # Raises IOError if reading is attempted. # # Related: StringIO#close, StringIO#close_write. # def close_read: () -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - close_write -> nil # --> # Closes `self` for writing; closed-read setting remains unchanged. # # Raises IOError if writing is attempted. # # Related: StringIO#close, StringIO#close_read. # def close_write: () -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - closed? -> true or false # --> # Returns `true` if `self` is closed for both reading and writing, `false` # otherwise. # def closed?: () -> bool # <!-- # rdoc-file=ext/stringio/stringio.c # - closed_read? -> true or false # --> # Returns `true` if `self` is closed for reading, `false` otherwise. # def closed_read?: () -> bool # <!-- # rdoc-file=ext/stringio/stringio.c # - closed_write? -> true or false # --> # Returns `true` if `self` is closed for writing, `false` otherwise. # def closed_write?: () -> bool # <!-- # rdoc-file=ext/stringio/stringio.c # - each_line(sep = $/, chomp: false) {|line| ... } -> self # - each_line(limit, chomp: false) {|line| ... } -> self # - each_line(sep, limit, chomp: false) {|line| ... } -> self # --> # Calls the block with each remaining line read from the stream; does nothing if # already at end-of-file; returns `self`. See [Line IO](rdoc-ref:IO@Line+IO). # def each: (?String sep, ?Integer limit, ?chomp: boolish) { (String) -> untyped } -> self | (?String sep, ?Integer limit, ?chomp: boolish) -> ::Enumerator[String, self] # <!-- # rdoc-file=ext/stringio/stringio.c # - each_byte {|byte| ... } -> self # --> # With a block given, calls the block with each remaining byte in the stream; # see [Byte IO](rdoc-ref:IO@Byte+IO). # # With no block given, returns an enumerator. # def each_byte: () { (Integer arg0) -> untyped } -> self | () -> ::Enumerator[Integer, self] # <!-- # rdoc-file=ext/stringio/stringio.c # - each_char {|c| ... } -> self # --> # With a block given, calls the block with each remaining character in the # stream; see [Character IO](rdoc-ref:IO@Character+IO). # # With no block given, returns an enumerator. # def each_char: () { (String arg0) -> untyped } -> self | () -> ::Enumerator[String, self] # <!-- # rdoc-file=ext/stringio/stringio.c # - each_codepoint {|codepoint| ... } -> self # --> # With a block given, calls the block with each remaining codepoint in the # stream; see [Codepoint IO](rdoc-ref:IO@Codepoint+IO). # # With no block given, returns an enumerator. # def each_codepoint: () { (Integer arg0) -> untyped } -> self | () -> ::Enumerator[Integer, self] # <!-- # rdoc-file=ext/stringio/stringio.c # - eof? -> true or false # --> # Returns `true` if positioned at end-of-stream, `false` otherwise; see # [Position](rdoc-ref:IO@Position). # # Raises IOError if the stream is not opened for reading. # def eof: () -> bool # <!-- # rdoc-file=ext/stringio/stringio.c # - fcntl(*args) # --> # Raises NotImplementedError. # def fcntl: (Integer integer_cmd, String | Integer arg) -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - fileno() # --> # Returns `nil`. Just for compatibility to IO. # def fileno: () -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - flush() # --> # Returns an object itself. Just for compatibility to IO. # def flush: () -> self # <!-- # rdoc-file=ext/stringio/stringio.c # - fsync() # --> # Returns 0. Just for compatibility to IO. # def fsync: () -> Integer? # <!-- # rdoc-file=ext/stringio/stringio.c # - getbyte -> byte or nil # --> # Reads and returns the next 8-bit byte from the stream; see [Byte # IO](rdoc-ref:IO@Byte+IO). # def getbyte: () -> Integer? # <!-- # rdoc-file=ext/stringio/stringio.c # - getc -> character or nil # --> # Reads and returns the next character from the stream; see [Character # IO](rdoc-ref:IO@Character+IO). # def getc: () -> String? # <!-- # rdoc-file=ext/stringio/stringio.c # - gets(sep = $/, chomp: false) -> string or nil # - gets(limit, chomp: false) -> string or nil # - gets(sep, limit, chomp: false) -> string or nil # --> # Reads and returns a line from the stream; assigns the return value to `$_`; # see [Line IO](rdoc-ref:IO@Line+IO). # def gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String? # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.internal_encoding => encoding # --> # Returns the Encoding of the internal string if conversion is specified. # Otherwise returns `nil`. # def internal_encoding: () -> Encoding # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.external_encoding => encoding # --> # Returns the Encoding object that represents the encoding of the file. If the # stream is write mode and no encoding is specified, returns `nil`. # def external_encoding: () -> Encoding # <!-- # rdoc-file=ext/stringio/stringio.c # - isatty() # --> # Returns `false`. Just for compatibility to IO. # def isatty: () -> bool # <!-- # rdoc-file=ext/stringio/stringio.c # - lineno -> current_line_number # --> # Returns the current line number in `self`; see [Line # Number](rdoc-ref:IO@Line+Number). # def lineno: () -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - lineno = new_line_number -> new_line_number # --> # Sets the current line number in `self` to the given `new_line_number`; see # [Line Number](rdoc-ref:IO@Line+Number). # def lineno=: (Integer arg0) -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - pid() # --> # Returns `nil`. Just for compatibility to IO. # def pid: () -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - pos -> stream_position # --> # Returns the current position (in bytes); see [Position](rdoc-ref:IO@Position). # def pos: () -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - pos = new_position -> new_position # --> # Sets the current position (in bytes); see [Position](rdoc-ref:IO@Position). # def pos=: (Integer arg0) -> Integer def print: (*untyped arg0) -> nil def printf: (String format_string, *untyped arg0) -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.putc(obj) -> obj # --> # See IO#putc. # def putc: (Numeric | String arg0) -> untyped def puts: (*untyped arg0) -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.read([length [, outbuf]]) -> string, outbuf, or nil # --> # See IO#read. # def read: (?int? length, ?string outbuf) -> String? def read_nonblock: (int len, ?string buf) -> String def readbyte: () -> Integer def readchar: () -> String def readline: (?String sep, ?Integer limit) -> String # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.readlines(sep=$/, chomp: false) -> array # - strio.readlines(limit, chomp: false) -> array # - strio.readlines(sep, limit, chomp: false) -> array # --> # See IO#readlines. # def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String] def readpartial: (int maxlen, ?string outbuf) -> String # <!-- # rdoc-file=ext/stringio/stringio.c # - reopen(other, mode = 'r+') -> self # --> # Reinitializes the stream with the given `other` (string or StringIO) and # `mode`; see IO.new: # # StringIO.open('foo') do |strio| # p strio.string # strio.reopen('bar') # p strio.string # other_strio = StringIO.new('baz') # strio.reopen(other_strio) # p strio.string # other_strio.close # end # # Output: # # "foo" # "bar" # "baz" # def reopen: (StringIO other) -> self | (String other, ?String mode_str) -> self # <!-- # rdoc-file=ext/stringio/stringio.c # - rewind -> 0 # --> # Sets the current position and line number to zero; see # [Position](rdoc-ref:IO@Position) and [Line Number](rdoc-ref:IO@Line+Number). # def rewind: () -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - seek(offset, whence = SEEK_SET) -> 0 # --> # Sets the current position to the given integer `offset` (in bytes), with # respect to a given constant `whence`; see [Position](rdoc-ref:IO@Position). # def seek: (Integer amount, ?Integer whence) -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.set_encoding(ext_enc, [int_enc[, opt]]) => strio # --> # Specify the encoding of the StringIO as *ext_enc*. Use the default external # encoding if *ext_enc* is nil. 2nd argument *int_enc* and optional hash *opt* # argument are ignored; they are for API compatibility to IO. # def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self | (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self # <!-- # rdoc-file=ext/stringio/stringio.c # - string -> string # --> # Returns underlying string: # # StringIO.open('foo') do |strio| # p strio.string # strio.string = 'bar' # p strio.string # end # # Output: # # "foo" # "bar" # # Related: StringIO#string= (assigns the underlying string). # def string: () -> String # <!-- # rdoc-file=ext/stringio/stringio.c # - string = other_string -> other_string # --> # Assigns the underlying string as `other_string`, and sets position to zero; # returns `other_string`: # # StringIO.open('foo') do |strio| # p strio.string # strio.string = 'bar' # p strio.string # end # # Output: # # "foo" # "bar" # # Related: StringIO#string (returns the underlying string). # def string=: (String str) -> String # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.length -> integer # - strio.size -> integer # --> # Returns the size of the buffer string. # def size: () -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - sync -> true # --> # Returns `true`; implemented only for compatibility with other stream classes. # def sync: () -> bool # <!-- # rdoc-file=ext/stringio/stringio.c # - sync=(p1) # --> # Returns the argument unchanged. Just for compatibility to IO. # def sync=: (boolish) -> bool def sysread: (Integer maxlen, String outbuf) -> String def syswrite: (String arg0) -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - pos -> stream_position # --> # Returns the current position (in bytes); see [Position](rdoc-ref:IO@Position). # def tell: () -> Integer # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.truncate(integer) -> 0 # --> # Truncates the buffer string to at most *integer* bytes. The stream must be # opened for writing. # def truncate: (Integer) -> 0 # <!-- rdoc-file=ext/stringio/stringio.c --> # Returns `false`. Just for compatibility to IO. # def tty?: () -> bool # <!-- # rdoc-file=ext/stringio/stringio.c # - ungetbyte(byte) -> nil # --> # Pushes back ("unshifts") an 8-bit byte onto the stream; see [Byte # IO](rdoc-ref:IO@Byte+IO). # def ungetbyte: (String | Integer arg0) -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - ungetc(character) -> nil # --> # Pushes back ("unshifts") a character or integer onto the stream; see # [Character IO](rdoc-ref:IO@Character+IO). # def ungetc: (String arg0) -> nil # <!-- # rdoc-file=ext/stringio/stringio.c # - strio.write(string, ...) -> integer # - strio.syswrite(string) -> integer # --> # Appends the given string to the underlying buffer string. The stream must be # opened for writing. If the argument is not a string, it will be converted to # a string using `to_s`. Returns the number of bytes written. See IO#write. # def write: (*_ToS) -> Integer # This is a deprecated alias for #each_byte. # def bytes: () { (Integer arg0) -> untyped } -> self | () -> ::Enumerator[Integer, self] # This is a deprecated alias for #each_char. # def chars: () { (String arg0) -> untyped } -> self | () -> ::Enumerator[String, self] # This is a deprecated alias for #each_codepoint. # def codepoints: () { (Integer arg0) -> untyped } -> self | () -> ::Enumerator[Integer, self] # <!-- rdoc-file=ext/stringio/stringio.c --> # Calls the block with each remaining line read from the stream; does nothing if # already at end-of-file; returns `self`. See [Line IO](rdoc-ref:IO@Line+IO). # def each_line: (?String sep, ?Integer limit, ?chomp: boolish) { (String) -> untyped } -> self | (?String sep, ?Integer limit, ?chomp: boolish) -> ::Enumerator[String, self] # <!-- rdoc-file=ext/stringio/stringio.c --> # Returns `true` if positioned at end-of-stream, `false` otherwise; see # [Position](rdoc-ref:IO@Position). # # Raises IOError if the stream is not opened for reading. # def eof?: () -> bool # This is a deprecated alias for #each_line. # def lines: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self | (?String sep, ?Integer limit) -> ::Enumerator[String, self] end