Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string-ext.rb
Instance Method Summary collapse
Instance Method Details
#template(v = {}, delim = ':') ⇒ Object
2 3 4 5 6 |
# File 'lib/string-ext.rb', line 2 def template v={}, delim=':' v = v.stringify_keys re = Regexp.new("#{delim}([a-zA-Z][a-zA-Z0-9_]*)#{delim}") self.gsub(re) {|m| v[$1].to_s } end |