Module: Commonmarker::Utils
Constant Summary
Constants included from Constants
Instance Method Summary collapse
Instance Method Details
#fetch_kv(options, key, value, type) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/commonmarker/utils.rb', line 9 def fetch_kv(, key, value, type) value_klass = value.class if Constants::BOOLS.include?(value) && BOOLS.include?([key]) [key] elsif [key].is_a?(value_klass) [key] else expected_type = Constants::BOOLS.include?(value) ? "Boolean" : value_klass.to_s raise TypeError, "#{type} option `:#{key}` must be #{expected_type}; got #{[key].class}" end end |