Is it possible to specify formatting options for to_yaml in ruby?

前端 未结 5 1162
说谎
说谎 2020-12-11 14:36

The code

require \'yaml\'
puts YAML.load(\"
is_something:
  values: [\'yes\', \'no\']
\").to_yaml

produces

--- 
is_somethin         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 15:20

    The latest versions of Ruby use the Psych module for YAML parsing. There aren't many options that you can pass but you can change indention and line width. Check the latest Psych documentation for more details.

提交回复
热议问题