Class: YamlRefResolver::Yaml
- Inherits:
-
Object
- Object
- YamlRefResolver::Yaml
- Defined in:
- lib/yaml_ref_resolver/yaml.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, content, key) ⇒ Yaml
constructor
A new instance of Yaml.
- #refs ⇒ Object
Constructor Details
#initialize(path, content, key) ⇒ Yaml
Returns a new instance of Yaml.
18 19 20 21 22 |
# File 'lib/yaml_ref_resolver/yaml.rb', line 18 def initialize(path, content, key) @filepath = path @content = content @key = key end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/yaml_ref_resolver/yaml.rb', line 4 def content @content end |
Class Method Details
.load!(path:, key: '$ref') ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/yaml_ref_resolver/yaml.rb', line 6 def self.load!(path:, key: '$ref') if File.exist?(path) begin self.new(path, YAML.load_file(path), key) rescue Psych::SyntaxError => e raise YamlRefResolver::YamlSyntaxErrorException.new(exception: e) end else raise YamlRefResolver::YamlNotFoundException.new(path: path) end end |
Instance Method Details
#refs ⇒ Object
24 25 26 27 28 |
# File 'lib/yaml_ref_resolver/yaml.rb', line 24 def refs find_refs(@content).flatten.compact.map do |ref| YamlRefResolver::Ref.new(ref, @filepath) end end |