On 10/10/2014 07:57 PM, Spriya wrote:
> Hi,
>
> require 'facter'
>
> ary = [1,2,3,4,5]
>
> ary.each do |numbers|
> Facter.add("base") do
> setcode do
> "#{numbers} "
> end
> end
> end
>
> In the fact it is returning only 1 value. In the fact it is returning
> base = 1 only not returning 2 3 4
First off, this description is way too vague to even start guessing
where you are going with this. It would be helpful if you can describe
what you are trying to solve in the long run.
Anyway, here is what I think you may want. Perhaps.
ary.each do |num|
Facter.add("base#{num}") do
setcode { num.to_s }
end
end
You get five facts, with the value equal to the respective index.
HTH,
Felix