class

RSub

Inherits Reference < Object

Constructors

new(string : String)
Source

Instance methods

gsub(string substring, &block : -> String)

Returns a String where all occurrences of the given string are replaced with the block’s value, starting from the RHS.

Example:

stack = ["a", "b"]

RSub.new("{} {}").gsub("{}") do stack.pop end

⇒ a b

Source
string
Source
string=(string : String)
Source
sub(string substring, &block : -> String)

Returns a String where the last occurrence of the given string is replaced with the block’s value.

Example:

stack = ["a", "b"]

RSub.new("{} {}").sub("{}") do stack.pop end

⇒ {} b

Source