Sha256: f281a3fd07a54681791192a7c949163bfff0db4c4beacf82d1fe9d856e1a0557
Contents?: true
Size: 544 Bytes
Versions: 10
Compression:
Stored size: 544 Bytes
Contents
class String # Apply a set of rules in the form of regular expression matches # to the string. # # * rules - The array containing rule-pairs (match, write). # # Keep in mind that the order of rules is significant. # # Returns the rewritten String. # # CREDIT: George Moschovitis def rewrite(rules) raise ArgumentError.new('The rules parameter is nil') unless rules rewritten_string = dup rules.each do |(match,write)| rewritten_string.gsub!(match,write) end return rewritten_string end end
Version data entries
10 entries across 9 versions & 2 rubygems