module Kramdown::Options
def self.define(name, type, default, desc, &block)
suffices. A block needs to be specified when using type 'Object' and it has to cope with
The type 'Object' should only be used for complex types for which none of the other types
specified, it should validate the value and either raise an error or return a valid value.
Symbol, Boolean, Object), default value +default+ and the description +desc+. If a block is
Define a new option called +name+ (a Symbol) with the given +type+ (String, Integer, Float,
def self.define(name, type, default, desc, &block) name = name.to_sym raise ArgumentError, "Option name #{name} is already used" if @options.has_key?(name) raise ArgumentError, "Invalid option type #{type} specified" if !ALLOWED_TYPES.include?(type) raise ArgumentError, "Invalid type for default value" if !(type === default) && !default.nil? raise ArgumentError, "Missing validator block" if type == Object && block.nil? @options[name] = Definition.new(name, type, default, desc, block) end