Sha256: 98e955ebec8014badf0fbbabf28a5bf8d6db0f4cd651544baf70c14bd7a374ed
Contents?: true
Size: 650 Bytes
Versions: 11
Compression:
Stored size: 650 Bytes
Contents
# frozen_string_literal: true module DiverDown class Web class DefinitionLoader # @param path [String] def load_file(path) hash = case File.extname(path) when '.yaml', '.yml' from_yaml(path) when '.json' from_json(path) else raise ArgumentError, "Unsupported file type: #{path}" end DiverDown::Definition.from_hash(hash) end private def from_json(path) JSON.parse(File.read(path)) end def from_yaml(path) YAML.load_file(path) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems