Sha256: a7bd4f8200a0e65b41c0e9714db99d3004b6ba6168692ffeeea7549d3b9f7b74
Contents?: true
Size: 322 Bytes
Versions: 1
Compression:
Stored size: 322 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]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stir-2.2.2 | lib/stir/core_ext/string.rb |