I don't know the first thing about ruby, but I'd like to transform values in a hash.
The following works in pure ruby:
def replace(hash)
hash.inject({}) do |h,(k,v)|
if v.kind_of? String
h[k] = v.upcase
elsif v.kind_of? Fixnum
h[k] = v
else
h[k] = replace(v)
end
h
end
end
but when I try to use it inside a Vagrantfile, I get errors about inject being undefined:
/home/mav/Workspaces/i2/new/vagrant_functions/utility.rb:141:in `replace': undefined method `inject' for nil:NilClass (NoMethodError)
is there any documentation on how to use ruby in vagrantfiles?
Thanks a lot!