Class: Lutaml::Model::Yamls::StandardAdapter
- Inherits:
-
Document
- Object
- Document
- Lutaml::Model::Yamls::StandardAdapter
show all
- Defined in:
- lib/lutaml/model/yamls/standard_adapter.rb
Constant Summary
collapse
- FORMAT_SYMBOL =
:yaml
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Document
#initialize
Class Method Details
.parse(yamls, _options = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/lutaml/model/yamls/standard_adapter.rb', line 10
def self.parse(yamls, _options = {})
results = []
yamls.split(/^---\n/).each do |yaml|
next if yaml.strip.empty?
begin
results << YAML.safe_load(yaml, aliases: true)
rescue Psych::SyntaxError => e
warn "Skipping invalid yaml: #{e.message}"
end
end
results
end
|
Instance Method Details
#to_yamls(*_args) ⇒ Object
26
27
28
29
30
|
# File 'lib/lutaml/model/yamls/standard_adapter.rb', line 26
def to_yamls(*_args)
@yamls.map do |yaml|
YAML.dump(yaml).strip
end.join("\n")
end
|