Sha256: 7de5bf655eebf36585db7e22650e448df845f68e3ea302d92c39c084243e74b2

Contents?: true

Size: 958 Bytes

Versions: 36

Compression:

Stored size: 958 Bytes

Contents

module Inch
  module Evaluation
    # PriorityRange objects are used to associate a given
    # range of priorities with a symbol and an arrow.
    #
    class PriorityRange
      extend Utils::ReadWriteMethods
      extend Forwardable

      rw_methods %w(priorities arrow)

      def_delegators :priorities, :include?, :min, :max

      def initialize(symbol)
        @symbol = symbol
      end

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

      def to_sym
        @symbol
      end

      def to_s
        arrow
      end

      class << self
        attr_reader :priority_map

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

        def priority_range(symbol, &block)
          @priority_map ||= {}
          @priority_map[symbol] ||= PriorityRange.new(symbol)
          @priority_map[symbol].update(&block) if block
          @priority_map[symbol]
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
inch-0.9.0.rc1 lib/inch/evaluation/priority_range.rb
inch-0.8.0 lib/inch/evaluation/priority_range.rb
inch-0.8.0.rc2 lib/inch/evaluation/priority_range.rb
inch-0.8.0.rc1 lib/inch/evaluation/priority_range.rb
inch-0.7.1 lib/inch/evaluation/priority_range.rb
inch-0.7.0 lib/inch/evaluation/priority_range.rb
inch-0.6.4 lib/inch/evaluation/priority_range.rb
inch-0.6.3 lib/inch/evaluation/priority_range.rb
inch-0.6.2 lib/inch/evaluation/priority_range.rb
inch-0.6.1 lib/inch/evaluation/priority_range.rb
inch-0.6.0 lib/inch/evaluation/priority_range.rb
inch-0.6.0.rc6 lib/inch/evaluation/priority_range.rb
inch-0.6.0.rc5 lib/inch/evaluation/priority_range.rb
inch-0.6.0.rc4 lib/inch/evaluation/priority_range.rb
inch-0.6.0.rc3 lib/inch/evaluation/priority_range.rb
inch-0.6.0.rc2 lib/inch/evaluation/priority_range.rb
inch-0.6.0.rc1 lib/inch/evaluation/priority_range.rb
inch-0.5.10 lib/inch/evaluation/priority_range.rb
inch-0.5.9 lib/inch/evaluation/priority_range.rb
inch-0.5.8 lib/inch/evaluation/priority_range.rb