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.
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"
Create a new InstanceVariableAndWriteNode
node
Create a new InstanceVariableOrWriteNode
node
Create a new InstanceVariableWriteNode
node
Create a new InterpolatedStringNode
node
Create a new InterpolatedXStringNode
node
Create a new StringNode
node
Create a new XStringNode
node