String

ruby/spec describes 153 methods in core/string, and Metorex implements 138 of them. The parameters are what Method#parameters answers under Metorex.

  • String#%: implemented, parameters [[:req]]. Returns the result of formatting object into the format specifications contained in self (see Format Specifications):
  • String#*: implemented, parameters [[:req]]. Returns a new string containing n copies of self:
  • String#+: implemented, parameters [[:req]]. Returns a new string containing other_string concatenated to self:
  • String#+@: implemented, parameters []. Returns self if self is not frozen and can be mutated without warning issuance.
  • String#-@: implemented, parameters []. Returns a frozen string equal to self.
  • String#<<: implemented, parameters [[:req]]. Appends a string representation of object to self; returns self.
  • String#<=>: implemented, parameters [[:req]]. Compares self and other, evaluating their contents, not their lengths.
  • String#==: implemented, parameters [[:req]]. Returns whether object is equal to self.
  • String#===: implemented, parameters [[:req]]. Returns whether object is equal to self.
  • String#=~: implemented, parameters [[:req]]. When object is a Regexp, returns the index of the first substring in self matched by object, or nil if no match is found; updates Regexp-related global variables:
  • String#[]: implemented, parameters [[:rest]]. Returns the substring of self specified by the arguments.
  • String#[]=: implemented, parameters [[:rest]]. Returns self with all, a substring, or none of its contents replaced; returns the argument other_string.
  • String.allocate: implemented, parameters [[:req, :args]].
  • String#append_bytes: not implemented.
  • String#ascii_only?: implemented, parameters []. Returns whether self contains only ASCII characters: An example calling it.
  • String#b: implemented, parameters []. Returns a copy of self that has ASCII-8BIT encoding; the underlying bytes are not modified: An example calling it.
  • String#bit_clear: not implemented.
  • String#bit_count: not implemented.
  • String#bit_flip: not implemented.
  • String#bit_get: not implemented.
  • String#bit_set: not implemented.
  • String#bit_set?: not implemented.
  • String#bitwise_and: not implemented.
  • String#bitwise_and!: not implemented.
  • String#bitwise_not: not implemented.
  • String#bitwise_not!: not implemented.
  • String#bitwise_or: not implemented.
  • String#bitwise_or!: not implemented.
  • String#bitwise_xor: not implemented.
  • String#bitwise_xor!: not implemented.
  • String#byteindex: implemented, parameters [[:rest]]. Returns the 0-based integer index of a substring of self specified by object (a string or Regexp) and offset, or nil if there is no such substring; the returned index is the count of bytes (not characters). An example calling it.
  • String#byterindex: implemented, parameters [[:rest]]. Returns the 0-based integer index of a substring of self that is the last match for the given object (a string or Regexp) and offset, or nil if there is no such substring; the returned index is the count of bytes (not characters). An example calling it.
  • String#bytes: implemented, parameters []. Returns an array of the bytes in self: An example calling it.
  • String#bytesize: implemented, parameters []. Returns the count of bytes in self. An example calling it.
  • String#byteslice: implemented, parameters [[:rest]]. Returns a substring of self, or nil if the substring cannot be constructed. An example calling it.
  • String#bytesplice: implemented, parameters [[:rest]]. Replaces target bytes in self with source bytes from the given string str; returns self. An example calling it.
  • String#capitalize: implemented, parameters [[:rest]]. Returns a string containing the characters in self, each with possibly changed case: An example calling it.
  • String#capitalize!: implemented, parameters [[:rest]]. Like String#capitalize, except that:
  • String#casecmp: implemented, parameters [[:req]]. Ignoring case, compares self and other_string; returns: An example calling it.
  • String#casecmp?: implemented, parameters [[:req]]. Returns true if self and other_string are equal after Unicode case folding, false if unequal, nil if incomparable. An example calling it.
  • String#center: implemented, parameters [[:rest]]. Returns a centered copy of self. An example calling it.
  • String#chars: implemented, parameters []. Returns an array of the characters in self: An example calling it.
  • String#chomp: implemented, parameters [[:rest]]. Returns a new string copied from self, with trailing characters possibly removed: An example calling it.
  • String#chomp!: implemented, parameters [[:rest]]. Like String#chomp, except that: An example calling it.
  • String#chop: implemented, parameters []. Returns a new string copied from self, with trailing characters possibly removed. An example calling it.
  • String#chop!: implemented, parameters []. Like String#chop, except that:
  • String#chr: implemented, parameters []. Returns a string containing the first character of self: An example calling it.
  • String#clear: implemented, parameters []. Removes the contents of self: An example calling it.
  • String#clone: implemented, parameters [[:rest, :args]]. Produces a shallow copy of obj---the instance variables of obj are copied, but not the objects they reference. An example calling it.
  • String#codepoints: implemented, parameters []. Returns an array of the codepoints in self; each codepoint is the integer value for a character: An example calling it.
  • String#concat: implemented, parameters [[:rest]]. Concatenates each object in objects to self; returns self: An example calling it.
  • String#count: implemented, parameters [[:rest]]. Returns the total number of characters in self that are specified by the given selectors. An example calling it.
  • String#crypt: implemented, parameters [[:req]]. Returns the string generated by calling crypt(3) standard library function with str and salt_str, in this order, as its arguments. An example calling it.
  • String#dedup: implemented, parameters []. Returns a frozen string equal to self.
  • String#delete: implemented, parameters [[:rest]]. Returns a new string that is a copy of self with certain characters removed; the removed characters are all instances of those specified by the given string selectors. An example calling it.
  • String#delete!: implemented, parameters [[:rest]]. Like String#delete, but modifies self in place; returns self if any characters were deleted, nil otherwise. An example calling it.
  • String#delete_prefix: implemented, parameters [[:req]]. Returns a copy of self with leading substring prefix removed: An example calling it.
  • String#delete_prefix!: implemented, parameters [[:req]]. Like String#delete_prefix, except that self is modified in place; returns self if the prefix is removed, nil otherwise. An example calling it.
  • String#delete_suffix: implemented, parameters [[:req]]. Returns a copy of self with trailing substring suffix removed: An example calling it.
  • String#delete_suffix!: implemented, parameters [[:req]]. Like String#delete_suffix, except that self is modified in place; returns self if the suffix is removed, nil otherwise. An example calling it.
  • String#downcase: implemented, parameters [[:rest]]. Returns a new string containing the downcased characters in self: An example calling it.
  • String#downcase!: implemented, parameters [[:rest]]. Like String#downcase, except that: An example calling it.
  • String#dump: implemented, parameters []. For an ordinary string, this method, +String#dump+, returns a printable ASCII-only version of self, enclosed in double-quotes. An example calling it.
  • String#dup: implemented, parameters []. Produces a shallow copy of obj---the instance variables of obj are copied, but not the objects they reference. An example calling it.
  • String#each_byte: implemented, parameters []. With a block given, calls the block with each successive byte from self; returns self: An example calling it.
  • String#each_char: implemented, parameters []. With a block given, calls the block with each successive character from self; returns self: An example calling it.
  • String#each_codepoint: implemented, parameters []. With a block given, calls the block with each successive codepoint from self; each codepoint is the integer value for a character; returns self: An example calling it.
  • String#each_grapheme_cluster: implemented, parameters []. With a block given, calls the given block with each successive grapheme cluster from self (see Unicode Grapheme Cluster Boundaries ); returns self:
  • String#each_line: implemented, parameters [[:rest]]. With a block given, forms the substrings (lines) that are the result of splitting self at each occurrence of the given record_separator; passes each line to the block; returns self. An example calling it.
  • String#empty?: implemented, parameters []. Returns whether the length of self is zero: An example calling it.
  • String#encode: implemented, parameters [[:rest]]. Returns a copy of self transcoded as determined by dst_encoding; see Encodings. An example calling it.
  • String#encode!: implemented, parameters [[:rest]]. Like #encode, but applies encoding changes to self; returns self. An example calling it.
  • String#encoding: implemented, parameters []. Returns an Encoding object that represents the encoding of self; see Encodings. An example calling it.
  • String#end_with?: implemented, parameters [[:rest]]. Returns whether self ends with any of the given strings: An example calling it.
  • String#eql?: implemented, parameters [[:req]]. Returns whether self and object have the same length and content: An example calling it.
  • String#force_encoding: implemented, parameters [[:req]]. Changes the encoding of self to the given encoding, which may be a string encoding name or an Encoding object; does not change the underlying bytes; returns self: An example calling it.
  • String#freeze: implemented, parameters []. Prevents further modifications to obj. An example calling it.
  • String#getbyte: implemented, parameters [[:req]]. Returns the byte at zero-based index as an integer: An example calling it.
  • String#grapheme_clusters: implemented, parameters []. Returns an array of the grapheme clusters in self (see Unicode Grapheme Cluster Boundaries ):
  • String#gsub: implemented, parameters [[:rest]]. Returns a copy of self with zero or more substrings replaced. An example calling it.
  • String#gsub!: implemented, parameters [[:rest]]. Like String#gsub, except that: An example calling it.
  • String#hash: implemented, parameters []. Returns the integer hash value for self. An example calling it.
  • String#hex: implemented, parameters []. Interprets the leading substring of self as hexadecimal, possibly signed; returns its value as an integer. An example calling it.
  • String#include?: implemented, parameters [[:req]]. Returns whether self contains other_string: An example calling it.
  • String#index: implemented, parameters [[:rest]]. Returns the integer position of the first substring that matches the given argument pattern, or nil if none found. An example calling it.
  • String#initialize: implemented, parameters [[:opt, :other]]. An example calling it.
  • String#insert: implemented, parameters [[:req], [:req]]. Inserts the given other_string into self; returns self. An example calling it.
  • String#inspect: implemented, parameters []. Returns a printable version of self, enclosed in double-quotes. An example calling it.
  • String#intern: implemented, parameters []. Returns the Symbol object derived from self, creating it if it did not already exist: An example calling it.
  • String#length: implemented, parameters []. Returns the count of characters (not bytes) in self: An example calling it.
  • String#lines: implemented, parameters [[:rest]]. Returns substrings ("lines") of self according to the given arguments: An example calling it.
  • String#ljust: implemented, parameters [[:rest]]. Returns a copy of self, left-justified and, if necessary, right-padded with the pad_string: An example calling it.
  • String#lstrip: implemented, parameters [[:rest]]. Returns a copy of self with leading whitespace removed; see Whitespace in Strings: An example calling it.
  • String#lstrip!: implemented, parameters [[:rest]]. Like String#lstrip, except that:
  • String#match: implemented, parameters [[:rest]]. Creates a MatchData object based on self and the given arguments; updates Regexp Global Variables. An example calling it.
  • String#match?: implemented, parameters [[:rest]]. Returns whether a match is found for self and the given arguments; does not update Regexp Global Variables. An example calling it.
  • String.new: implemented, parameters [[:rest]]. Returns a new String object containing the given string. An example calling it.
  • String#next: implemented, parameters []. Returns the successor to self. An example calling it.
  • String#next!: implemented, parameters []. Like String#succ, but modifies self in place; returns self.
  • String#oct: implemented, parameters []. Interprets the leading substring of self as octal, binary, decimal, or hexadecimal, possibly signed; returns their value as an integer. An example calling it.
  • String#ord: implemented, parameters []. Returns the integer ordinal of the first character of self: An example calling it.
  • String#partition: implemented, parameters [[:req]]. Returns a 3-element array of substrings of self. An example calling it.
  • String#prepend: implemented, parameters [[:rest]]. Prefixes to self the concatenation of the given other_strings; returns self: An example calling it.
  • String#replace: implemented, parameters [[:req]]. Replaces the contents of self with the contents of other_string; returns self: An example calling it.
  • String#reverse: implemented, parameters []. Returns a new string with the characters from self in reverse order. An example calling it.
  • String#reverse!: implemented, parameters []. Returns self with its characters reversed: An example calling it.
  • String#rindex: implemented, parameters [[:rest]]. Returns the integer position of the last substring that matches the given argument pattern, or nil if none found. An example calling it.
  • String#rjust: implemented, parameters [[:rest]]. Returns a right-justified copy of self. An example calling it.
  • String#rpartition: implemented, parameters [[:req]]. Returns a 3-element array of substrings of self. An example calling it.
  • String#rstrip: implemented, parameters [[:rest]]. Returns a copy of self with trailing whitespace removed; see Whitespace in Strings: An example calling it.
  • String#rstrip!: implemented, parameters [[:rest]]. Like String#rstrip, except that:
  • String#scan: implemented, parameters [[:req]]. Matches a pattern against self: An example calling it.
  • String#scrub: implemented, parameters [[:rest]]. Returns a copy of self with each invalid byte sequence replaced by the given replacement_string.
  • String#scrub!: implemented, parameters [[:rest]]. Like String#scrub, except that: An example calling it.
  • String#setbyte: implemented, parameters [[:req], [:req]]. Sets the byte at zero-based offset index to the value of the given integer; returns integer: An example calling it.
  • String#size: implemented, parameters []. Returns the count of characters (not bytes) in self: An example calling it.
  • String#slice: implemented, parameters [[:rest]]. Returns the substring of self specified by the arguments. An example calling it.
  • String#slice!: implemented, parameters [[:rest]]. Like String#[] (and its alias String#slice), except that: An example calling it.
  • String#split: implemented, parameters [[:rest]]. Creates an array of substrings by splitting self at each occurrence of the given field separator field_sep. An example calling it.
  • String#squeeze: implemented, parameters [[:rest]]. Returns a copy of self with each tuple (doubling, tripling, etc.) of specified characters "squeezed" down to a single character. An example calling it.
  • String#squeeze!: implemented, parameters [[:rest]]. Like String#squeeze, except that:
  • String#start_with?: implemented, parameters [[:rest]]. Returns whether self starts with any of the given patterns. An example calling it.
  • String#strip: implemented, parameters [[:rest]]. Returns a copy of self with leading and trailing whitespace removed; see Whitespace in Strings: An example calling it.
  • String#strip!: implemented, parameters [[:rest]]. Like String#strip, except that: An example calling it.
  • String#sub: implemented, parameters [[:rest]]. Returns a copy of self, possibly with a substring replaced. An example calling it.
  • String#sub!: implemented, parameters [[:rest]]. Like String#sub, except that: An example calling it.
  • String#succ: implemented, parameters []. Returns the successor to self. An example calling it.
  • String#succ!: implemented, parameters []. Like String#succ, but modifies self in place; returns self.
  • String#sum: implemented, parameters [[:rest]]. Returns a basic n-bit checksum of the characters in self; the checksum is the sum of the binary value of each byte in self, modulo 2**n - 1: An example calling it.
  • String#swapcase: implemented, parameters [[:rest]]. Returns a string containing the characters in self, with cases reversed: An example calling it.
  • String#swapcase!: implemented, parameters [[:rest]]. Like String#swapcase, except that:
  • String#to_c: implemented, parameters []. Returns a Complex object: parses the leading substring of self to extract two numeric values that become the coordinates of the complex object. An example calling it.
  • String#to_f: implemented, parameters []. See Converting to Non-String. An example calling it.
  • String#to_i: implemented, parameters [[:rest]]. Returns the result of interpreting leading characters in self as an integer in the given base; base must be either 0 or in range (2..36): An example calling it.
  • String#to_r: implemented, parameters []. Returns the result of interpreting leading characters in self as a rational value: An example calling it.
  • String#to_s: implemented, parameters []. Returns self if self is a String, or self converted to a String if self is a subclass of String. An example calling it.
  • String#to_str: implemented, parameters []. Returns self if self is a String, or self converted to a String if self is a subclass of String. An example calling it.
  • String#to_sym: implemented, parameters []. Returns the Symbol object derived from self, creating it if it did not already exist: An example calling it.
  • String#tr: implemented, parameters [[:req], [:req]]. Returns a copy of self with each character specified by string selector translated to the corresponding character in string replacements. An example calling it.
  • String#tr!: implemented, parameters [[:req], [:req]]. Like String#tr, except:
  • String#tr_s: implemented, parameters [[:req], [:req]]. Like String#tr, except: An example calling it.
  • String#tr_s!: implemented, parameters [[:req], [:req]]. Like String#tr_s, except:
  • String.try_convert: implemented, parameters [[:req, :args]]. Attempts to convert the given object to a string. An example calling it.
  • String#undump: implemented, parameters []. Inverse of String#dump; returns a copy of self with changes of the kinds made by String#dump "undone."
  • String#unicode_normalize: implemented, parameters [[:rest]]. Returns a copy of self with Unicode normalization applied. An example calling it.
  • String#unicode_normalize!: implemented, parameters [[:rest]]. Like String#unicode_normalize, except that the normalization is performed on self (not on a copy of self). An example calling it.
  • String#unicode_normalized?: implemented, parameters [[:rest]]. Returns whether self is in the given form of Unicode normalization; see String#unicode_normalize. An example calling it.
  • String#unpack: implemented, parameters [[:rest, :args]]. Extracts data from self to form new objects; see Packed Data. An example calling it.
  • String#unpack1: implemented, parameters [[:rest, :args]]. Like String#unpack with no block, but unpacks and returns only the first extracted object. An example calling it.
  • String#upcase: implemented, parameters [[:rest]]. Returns a new string containing the upcased characters in self: An example calling it.
  • String#upcase!: implemented, parameters [[:rest]]. Like String#upcase, except that: An example calling it.
  • String#upto: implemented, parameters [[:rest]]. With a block given, calls the block with each String value returned by successive calls to String#succ; the first value is self, the next is self.succ, and so on; the sequence terminates when value other_string is reached; returns self: An example calling it.
  • String#valid_encoding?: implemented, parameters []. Returns whether self is encoded correctly: An example calling it.

The method summaries are the first sentences of Ruby's own documentation for each method, read from MRI 4.0.6's ri data. Ruby's documentation is distributed under Ruby's license.