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 [stored string]:
scanner = StringScanner.new('foobar') scanner.string # => "foobar" scanner.concat('baz') scanner.string # => "foobarbaz"
Replaces the [stored string] with the given other_string:
Sets both [positions] to zero.
Clears [match values].
Returns other_string.
scanner = StringScanner.new('foobar') scanner.scan(/foo/) put_situation(scanner) # Situation: # pos: 3 # charpos: 3 # rest: "bar" # rest_size: 3 match_values_cleared?(scanner) # => false scanner.string = 'baz' # => "baz" put_situation(scanner) # Situation: # pos: 0 # charpos: 0 # rest: "baz" # rest_size: 3 match_values_cleared?(scanner) # => true
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 repository for the given string.
Returns an array of the entry names in the directory at dirpath; sets the given encoding onto each returned entry name:
Dir.entries('/example') # => ["config.h", "lib", "main.rb", "..", "."] Dir.entries('/example').first.encoding # => #<Encoding:UTF-8> Dir.entries('/example', encoding: 'US-ASCII').first.encoding # => #<Encoding:US-ASCII>
See String Encoding.
Raises an exception if the directory does not exist.
Returns a hash of values parsed from string according to the given format:
Date._strptime('2001-02-03', '%Y-%m-%d') # => {:year=>2001, :mon=>2, :mday=>3}
For other formats, see Formats for Dates and Times. (Unlike Date.strftime, does not support flags and width.)
See also strptime(3).
Related: Date.strptime (returns a Date object).
Returns a new Date object with values parsed from string, according to the given format:
Date.strptime('2001-02-03', '%Y-%m-%d') # => #<Date: 2001-02-03> Date.strptime('03-02-2001', '%d-%m-%Y') # => #<Date: 2001-02-03> Date.strptime('2001-034', '%Y-%j') # => #<Date: 2001-02-03> Date.strptime('2001-W05-6', '%G-W%V-%u') # => #<Date: 2001-02-03> Date.strptime('2001 04 6', '%Y %U %w') # => #<Date: 2001-02-03> Date.strptime('2001 05 6', '%Y %W %u') # => #<Date: 2001-02-03> Date.strptime('sat3feb01', '%a%d%b%y') # => #<Date: 2001-02-03>
For other formats, see Formats for Dates and Times. (Unlike Date.strftime, does not support flags and width.)
See argument start.
See also strptime(3).
Related: Date._strptime (returns a hash).
Returns a string representation of the date in self, formatted according the given format:
Date.new(2001, 2, 3).strftime # => "2001-02-03"
For other formats, see Formats for Dates and Times.