Module: Commonmarker::Utils
Constant Summary
Constants included from Constants
Instance Method Summary collapse
Instance Method Details
#fetch_kv(option, 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(option, key, value, type) value_klass = value.class if Constants::BOOLS.include?(value) && BOOLS.include?(option[key]) option[key] elsif option[key].is_a?(value_klass) option[key] else expected_type = Constants::BOOLS.include?(value) ? "Boolean" : value_klass.to_s raise TypeError, "#{type} option `:#{key}` must be #{expected_type}; got #{option[key].class}" end end |