Module: UtilityPack::CoreExtensions::String

Included in:
String
Defined in:
lib/utility_pack/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#fill(values = {}) ⇒ Object

returns a new string instance populated with the provided variable values. template variables are of the form :<variable name>. e.g. :name



7
8
9
10
11
12
13
# File 'lib/utility_pack/core_ext/string.rb', line 7

def fill(values = {})
  s = self.clone
  values.each do |key, value|
    s.gsub!(":#{key}", value.to_s) if value.respond_to? :to_s
  end
  s  
end