Class: VagrantPlugins::Dotvm::Replacer
- Inherits:
-
Object
- Object
- VagrantPlugins::Dotvm::Replacer
- Defined in:
- lib/vagrant-dotvm/replacer.rb
Instance Method Summary collapse
-
#initialize ⇒ Replacer
constructor
A new instance of Replacer.
- #limit(limit) ⇒ Object
- #on(target) ⇒ Object
- #result ⇒ Object
- #using(vars) ⇒ Object
Constructor Details
#initialize ⇒ Replacer
Returns a new instance of Replacer.
4 5 6 |
# File 'lib/vagrant-dotvm/replacer.rb', line 4 def initialize @limit = 10 end |
Instance Method Details
#limit(limit) ⇒ Object
18 19 20 21 |
# File 'lib/vagrant-dotvm/replacer.rb', line 18 def limit(limit) @limit = limit self end |
#on(target) ⇒ Object
8 9 10 11 |
# File 'lib/vagrant-dotvm/replacer.rb', line 8 def on(target) @target = target self end |
#result ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-dotvm/replacer.rb', line 23 def result 0.upto(@limit).each do |_| @replaced = 0 target = _replace_vars @target return target if @replaced == 0 end fail 'Too deep variables relations, possible recurrence.' end |
#using(vars) ⇒ Object
13 14 15 16 |
# File 'lib/vagrant-dotvm/replacer.rb', line 13 def using(vars) @vars = vars self end |