I have a YAML file with the following format
- make: toyota
group: popular
cn: FungTin
en: Toyota
id: 83
rank: 2 + %{random_number}
- make: honda
group: popular
cn: boontin
en: Honda
id: 121
rank: 3 + %{random_number}
And when I load the file.
MAKE = YAML.load_file("#{Rails.root}/config/data.yml")
I try to do a manipulation by doing:
MAKE['rank'] % {random_number: rand(-1.0..1.0).round(3)}
This results in no implicit conversion of String into Integer
error.
How can I achieve that?
Your
MAKE
returning an aarray of hash
as following, so you should choose an element for perform an operationTry this
For get summation use
eval