Sha256: e67c266f4a179a60f2e20b76d2f9d5b8d43da61e342aa00d708eaec5ae51905f
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'ruby-enum' module CommonMarker # For Ruby::Enum, these must be classes, not modules module Config class Parse include Ruby::Enum define :default, 0 define :normalize, 4 define :validate_utf8, 16 define :smart, 8 end class Render include Ruby::Enum define :default, 0 define :sourcepos, 1 define :hardbreaks, 2 define :safe, 32 end def self.process_options(option, type) type = Config.const_get(type.capitalize) if option.is_a?(Symbol) check_option(option, type) type.to_h[option] elsif option.is_a?(Array) option = [nil] if option.empty? # neckbearding around. the map will both check the opts and then bitwise-OR it option.map { |o| check_option(o, type); type.to_h[o] }.inject(0, :|) else fail TypeError, 'option type must be a valid symbol or array of symbols' end end def self.check_option(option, type) unless type.keys.include?(option) fail TypeError, "option ':#{option}' does not exist for #{type}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
commonmarker-0.5.1 | lib/commonmarker/config.rb |