Sha256: 73364852ebdcc5150eb804c9c1f3822ad8f330a934030865b31ccb92566a325f

Contents?: true

Size: 683 Bytes

Versions: 15

Compression:

Stored size: 683 Bytes

Contents

module Skeptic
  class RuleTable
    def initialize
      @rules = {}
    end

    def rules
      @rules.keys
    end

    def register(klass, option_type)
      @rules[klass] = option_type
    end

    def slugs
      @rules.keys.map { |klass| slug_for klass }
    end

    def each_rule
      @rules.each do |klass, option_type|
        yield klass, slug_for(klass), option_type, description_for(klass)
      end
    end

    private

    def description_for(klass)
      klass.const_get(:DESCRIPTION)
    end

    def slug_for(klass)
      klass
        .name
        .gsub(/.*::/, '')
        .gsub(/([a-z])([A-Z])/, '\1_\2')
        .downcase
        .to_sym
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
skeptic-0.0.16 lib/skeptic/rule_table.rb
skeptic-0.0.15 lib/skeptic/rule_table.rb
skeptic-0.0.14 lib/skeptic/rule_table.rb
skeptic-0.0.12 lib/skeptic/rule_table.rb
skeptic-0.0.11 lib/skeptic/rule_table.rb
skeptic-0.0.10 lib/skeptic/rule_table.rb
skeptic-0.0.9 lib/skeptic/rule_table.rb
skeptic-0.0.8 lib/skeptic/rule_table.rb
skeptic-0.0.7 lib/skeptic/rule_table.rb
skeptic-0.0.6 lib/skeptic/rule_table.rb
skeptic-0.0.5 lib/skeptic/rule_table.rb
skeptic-0.0.4 lib/skeptic/rule_table.rb
skeptic-0.0.3 lib/skeptic/rule_table.rb
skeptic-0.0.2 lib/skeptic/rule_table.rb
skeptic-0.0.1 lib/skeptic/rule_table.rb