Sha256: 68ec3b2374da61f7ac3fa3fb572f9eb26ba34b42566124448a9b0e207e1295ea

Contents?: true

Size: 605 Bytes

Versions: 24

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

require "commonmarker/constants"

module Commonmarker
  module Utils
    include Commonmarker::Constants

    def fetch_kv(options, key, value, type)
      value_klass = value.class

      if Constants::BOOLS.include?(value) && BOOLS.include?(options[key])
        options[key]
      elsif options[key].is_a?(value_klass)
        options[key]
      else
        expected_type = Constants::BOOLS.include?(value) ? "Boolean" : value_klass.to_s
        raise TypeError, "#{type} option `:#{key}` must be #{expected_type}; got #{options[key].class}"
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
commonmarker-2.0.2.1-arm64-darwin lib/commonmarker/utils.rb
commonmarker-2.0.2.1-x86_64-darwin lib/commonmarker/utils.rb
commonmarker-2.0.2.1-x64-mingw-ucrt lib/commonmarker/utils.rb
commonmarker-2.0.2.1-x86_64-linux lib/commonmarker/utils.rb
commonmarker-2.0.2.1-aarch64-linux lib/commonmarker/utils.rb
commonmarker-2.0.2.1 lib/commonmarker/utils.rb
commonmarker-2.0.2-x86_64-darwin lib/commonmarker/utils.rb
commonmarker-2.0.2-arm64-darwin lib/commonmarker/utils.rb
commonmarker-2.0.2-x64-mingw-ucrt lib/commonmarker/utils.rb
commonmarker-2.0.2-aarch64-linux lib/commonmarker/utils.rb
commonmarker-2.0.2-x86_64-linux lib/commonmarker/utils.rb
commonmarker-2.0.2 lib/commonmarker/utils.rb
commonmarker-2.0.1-x86_64-linux lib/commonmarker/utils.rb
commonmarker-2.0.1-x64-mingw-ucrt lib/commonmarker/utils.rb
commonmarker-2.0.1-aarch64-linux lib/commonmarker/utils.rb
commonmarker-2.0.1-arm64-darwin lib/commonmarker/utils.rb
commonmarker-2.0.1-x86_64-darwin lib/commonmarker/utils.rb
commonmarker-2.0.1 lib/commonmarker/utils.rb
commonmarker-2.0.0-x86_64-linux lib/commonmarker/utils.rb
commonmarker-2.0.0-x86_64-darwin lib/commonmarker/utils.rb