Class: ProvisionVagrant::Interpolator
- Inherits:
-
Object
- Object
- ProvisionVagrant::Interpolator
- Defined in:
- lib/interpolator.rb
Constant Summary collapse
- DEFAULT_VAGRANTFILE_NAME =
"Vagrantfile.template"- DEFAULT_POST_HOOK_FILE_NAME =
"provision-vagrant.post-hook.sh"
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Interpolator
constructor
A new instance of Interpolator.
-
#interpolate ⇒ Object
Loops through a Hash (@vars) and replaces any of its keys found in the @input string with the corresponding hash values.
Constructor Details
#initialize(opts = {}) ⇒ Interpolator
Returns a new instance of Interpolator.
8 9 10 11 |
# File 'lib/interpolator.rb', line 8 def initialize(opts = {}) @vars = opts[:vars] @input = opts[:input] end |
Instance Method Details
#interpolate ⇒ Object
Loops through a Hash (@vars) and replaces any of its keys found in the @input string with the corresponding hash values
15 16 17 18 19 20 21 22 |
# File 'lib/interpolator.rb', line 15 def interpolate @vars.each do |k, v| var_wrapped = "{{#{k.to_s}}}" @input.gsub!(var_wrapped, v.to_s) end @input end |