Sha256: 0882faff50ed73e8009d5e324bb5f1bf9d9c468d015b3cbf0369872c2db7f6b1

Contents?: true

Size: 381 Bytes

Versions: 3

Compression:

Stored size: 381 Bytes

Contents

module Reality
  # @private
  module Refinements
    refine Hash do
      def except(*keys)
        reject { |k, _v| keys.include?(k) }
      end
    end

    refine Array do
      def group_count(&block)
        block ||= ->(x) { x }
        Hash.new{ 0 }.tap{|res|
          each do |val|
            res[block.call(val)] += 1
          end
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reality-0.1.0.alpha3 lib/reality/util/refinements.rb
reality-0.1.0.alpha2 lib/reality/util/refinements.rb
reality-0.1.0.alpha lib/reality/util/refinements.rb