Skip to content

Instantly share code, notes, and snippets.

@spanuska
Last active February 1, 2016 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spanuska/fe0b6442b104962d16d3 to your computer and use it in GitHub Desktop.
Save spanuska/fe0b6442b104962d16d3 to your computer and use it in GitHub Desktop.
class Interpolater
attr_accessor :data, :template
def initialize(template, data)
@template = template
@data = data
replace_bracketed_words
end
def replace_bracketed_words
data.map do |pair|
template.gsub!(("{" + pair.first.to_s + "}"), pair.last)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment