Module | Rufus::Dollar |
In: |
lib/rufus/dollar.rb
|
VERSION | = | '1.0.4' |
Performs ‘dollar substitution’ on a piece of text with a given dictionary.
require 'rubygems' require 'rufus/dollar' h = { "name" => "Fred Brooke", "title" => "Silver Bullet" } puts Rufus::Dollar.dsub "${name} wrote '${title}'", h # => "Fred Brooke wrote 'Silver Bullet'"
puts Rufus::Dollar.dsub "${name} wrote ${title}", h # => "Fred Brooke wrote Silver Bullet" puts Rufus::Dollar.dsub "${name} wrote ${'title}", h # => 'Fred Brooke wrote "Silver Bullet"'