module Formattable

Public Instance Methods

format(string) click to toggle source
# File lib/modules/formattable.rb, line 2
def format string
  string.scan(/\[([^\]]*)\]/).flatten.inject(string) do |string, prop|
    begin
      value = self.send(prop).to_s
    rescue NoMethodError
      value = ''
    end
    string.gsub("[#{prop}]", value)
  end
end