Sha256: 994389c167a96c18ee2ac9dee54233dbd7249e8e79bf957c52fc550bb0745c71
Contents?: true
Size: 328 Bytes
Versions: 1
Compression:
Stored size: 328 Bytes
Contents
module CoreExt module String def interpolate(h) return self if h.nil? self.gsub(/%({\w+})/) do |match| return self if match.nil? key = $1.tr('{}', '').to_sym raise KeyError.new("key{#{key}} not found") unless h.has_key?(key) CGI::escape(h[key].to_s) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stir-2.2.3 | lib/stir/core_ext/string.rb |