Every to_yaml output have three leading dashes:
---
a:
b:
c: soemthing
How convert object to yaml without leading dashes?
Every to_yaml output have three leading dashes:
---
a:
b:
c: soemthing
How convert object to yaml without leading dashes?
Under the hood, to_yaml
uses Psych to parse and emit your data.
Though there are optional parameters you can specify (listed here), none suppress the leading dashes.
The simplest approach would be to gsub
away the dashes.
object.to_yaml.gsub(/^---$/, "")
From the YAML specification:
YAML uses three dashes (“---”) to separate directives from document content. This also serves to signal the start of a document if no directives are present.
That means: Your example starts as a valid YAML document should start. Nothing wrong with it.