Class
for reading entries out of a tar file
Like String#strip
, except that any modifications are made in self
; returns self
if any modification are made, nil
otherwise.
Related: String#lstrip!
, String#strip!
.
Returns a copy of self
with leading whitespace removed; see Whitespace in Strings:
whitespace = "\x00\t\n\v\f\r " s = whitespace + 'abc' + whitespace s # => "\u0000\t\n\v\f\r abc\u0000\t\n\v\f\r " s.lstrip # => "abc\u0000\t\n\v\f\r "
Related: String#rstrip
, String#strip
.
Returns a copy of the receiver with trailing whitespace removed; see Whitespace in Strings:
whitespace = "\x00\t\n\v\f\r " s = whitespace + 'abc' + whitespace s # => "\u0000\t\n\v\f\r abc\u0000\t\n\v\f\r " s.rstrip # => "\u0000\t\n\v\f\r abc"
Related: String#lstrip
, String#strip
.
Like String#lstrip
, except that any modifications are made in self
; returns self
if any modification are made, nil
otherwise.
Related: String#rstrip!
, String#strip!
.
Like String#rstrip
, except that any modifications are made in self
; returns self
if any modification are made, nil
otherwise.
Related: String#lstrip!
, String#strip!
.
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).
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).
Returns the string being scanned.
Changes the string being scanned to str
and resets the scanner. Returns str
.
Returns the target string if it was frozen; otherwise, returns a frozen copy of the target string:
m = /(.)(.)(\d+)(\d)/.match("THX1138.") # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8"> m.string # => "THX1138."
Returns a string converted from object
.
Tries to convert object
to a string using to_str
first and to_s
second:
String([0, 1, 2]) # => "[0, 1, 2]" String(0..5) # => "0..5" String({foo: 0, bar: 1}) # => "{:foo=>0, :bar=>1}"
Raises TypeError
if object
cannot be converted to a string.
Returns a string containing the IP address representation in canonical form.
Returns a string containing the RFC-2045-compliant Base64-encoding of bin
.
Per RFC 2045, the returned string may contain the URL-unsafe characters +
or /
; see Encoding Character Set above:
Base64.strict_encode64("\xFB\xEF\xBE") # => "++++\n" Base64.strict_encode64("\xFF\xFF\xFF") # => "////\n"
The returned string may include padding; see Padding above.
Base64.strict_encode64('*') # => "Kg==\n"
The returned string will have no newline characters, regardless of its length; see Newlines above:
Base64.strict_encode64('*') # => "Kg==" Base64.strict_encode64('*' * 46) # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
The string to be encoded may itself contain newlines, which will be encoded as ordinary Base64:
Base64.strict_encode64("\n\n\n") # => "CgoK" s = "This is line 1\nThis is line 2\n" Base64.strict_encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
Returns a string containing the decoding of an RFC-2045-compliant Base64-encoded string str
:
s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK" Base64.strict_decode64(s) # => "This is line 1\nThis is line 2\n"
Non-Base64 characters in str
not allowed; see Encoding Character Set above: these include newline characters and characters -
and /
:
Base64.strict_decode64("\n") # Raises ArgumentError Base64.strict_decode64('-') # Raises ArgumentError Base64.strict_decode64('_') # Raises ArgumentError
Padding in str
, if present, must be correct:
Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567" Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
Format and print out counters as a String
. This returns a non-empty content only when --yjit-stats
is enabled.
Returns help string of OLE method. If the help string is not found, then the method returns nil.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') method = WIN32OLE_METHOD.new(tobj, 'Navigate') puts method.helpstring # => Navigates to a URL or file.
Returns help string.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') puts tobj.helpstring # => Web Browser interface
Creates a new string of the given length and yields a zero-copy IO::Buffer
instance to the block which uses the string as a source. The block is expected to write to the buffer and the string will be returned.
IO::Buffer.string(4) do |buffer| buffer.set_string("Ruby") end # => "Ruby"