Module: File::YAML

Defined in:
lib/ruuuby/class/io/file.rb

Overview

Class Method Summary collapse

Class Method Details

.read(path) ⇒ Hash

Parameters:

Returns:

Raises:

  • (ArgumentError)


155
156
157
158
# File 'lib/ruuuby/class/io/file.rb', line 155

def self.read(path)
  πŸ›‘str❓('path', path)
  ::YAML.load_file(path)
end

.read!(path, expected_sections) ⇒ Hash

Parameters:

Returns:

Raises:

  • (ArgumentError)


166
167
168
169
170
171
172
173
174
175
# File 'lib/ruuuby/class/io/file.rb', line 166

def self.read!(path, expected_sections)
  πŸ›‘str❓('path', path)
  πŸ›‘ary❓('expected_sections', expected_sections)
  data = ::YAML.load_file(path)
  if (data.keys).β‰ˆβ‰ˆ(expected_sections)
    return data
  else
    πŸ›‘ ::RuntimeError.new("| c{File::YAML}-> m{read!} did not find sections{#{expected_sections.to_s}} at path{#{path.to_s}} |")
  end
end