Skip to content

Instantly share code, notes, and snippets.

@jschairb
Created July 6, 2012 02:10
Show Gist options
  • Save jschairb/3057629 to your computer and use it in GitHub Desktop.
Save jschairb/3057629 to your computer and use it in GitHub Desktop.
C-style interpolation in Ruby
TEMPLATE = "permit tcp any any eq {PORT}"
def generate_template(port)
TEMPLATE.gsub('{PORT}', port.to_s)
end
TEMPLATE = "permit tcp any any eq %{port}"
def generate_template(port)
TEMPLATE % { :port => port }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment