Sha256: 44991403bbe2b2f9d4ad588745bcb1800229b79a5f75e85e116ffafa52ddb563

Contents?: true

Size: 730 Bytes

Versions: 16

Compression:

Stored size: 730 Bytes

Contents

module Inch
  module Evaluation
    class Grade
      extend Utils::ReadWriteMethods

      rw_methods %w(scores label color bg_color)

      def initialize(symbol)
        @symbol = symbol
      end

      def update(&block)
        instance_eval(&block)
      end

      def to_sym
        @symbol
      end

      def to_s
        @symbol.to_s
      end

      class << self
        attr_reader :grade_map

        def all
          @grade_map ||= {}
          @grade_map.values
        end

        def grade(symbol, &block)
          @grade_map ||= {}
          @grade_map[symbol] ||= Grade.new(symbol)
          @grade_map[symbol].update(&block) if block
          @grade_map[symbol]
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
inch-0.3.3 lib/inch/evaluation/grade.rb
inch-0.3.3.rc1 lib/inch/evaluation/grade.rb
inch-0.3.2 lib/inch/evaluation/grade.rb
inch-0.3.2.rc2 lib/inch/evaluation/grade.rb
inch-0.3.2.rc1 lib/inch/evaluation/grade.rb
inch-0.3.1 lib/inch/evaluation/grade.rb
inch-0.3.1.rc6 lib/inch/evaluation/grade.rb
inch-0.3.1.rc5 lib/inch/evaluation/grade.rb
inch-0.3.1.rc4 lib/inch/evaluation/grade.rb
inch-0.3.1.rc3 lib/inch/evaluation/grade.rb
inch-0.3.1.rc2 lib/inch/evaluation/grade.rb
inch-0.3.1.rc1 lib/inch/evaluation/grade.rb
inch-0.3.0 lib/inch/evaluation/grade.rb
inch-0.3.0.rc3 lib/inch/evaluation/grade.rb
inch-0.3.0.rc2 lib/inch/evaluation/grade.rb
inch-0.3.0.rc1 lib/inch/evaluation/grade.rb