D
D
dr4k2018-10-15 21:05:00
ruby
dr4k, 2018-10-15 21:05:00

How to write in yaml?

user:
  name: Alex
  weight:
       value: 70
  growth:
    value: 80
  age:
    value: 35

def initialize(name)
   parsed = YAML.load_file('characteristic.yml')
   @name = parsed['player']['name']
   @weight = parsed['player']['weight']['value']
   @growth = parsed['player']['growth']['value']
   @age = parsed['player']['age']['value']
end

Good afternoon, I recently started learning ruby ​​and ran into a problem. How to write the existing variables after changing their values ​​into a new yaml file, with the same structure as the old one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AVKor, 2018-10-15
@AVKor

Here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question