Sha256: 87e57fefeb483ee46c7d90a9239e602dab70cf9312c71315b95ef8be552d9636

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

module Axiom
  class Aggregate

    # The count of a series of values
    class Count < Aggregate

      DEFAULT = 0

      # Return the count for a series of values
      #
      # @example
      #   count = Count.call(count, value)
      #
      # @param [Integer] count
      #
      # @param [Object] value
      #
      # @return [Integer]
      #
      # @api public
      def self.call(count, value)
        value.nil? ? count : count.succ
      end

      # Return the type returned from #call
      #
      # @example
      #   type = Axiom::Aggregate::Count.type
      #
      # @return [Class<Attribute::Integer>]
      #
      # @api public
      def type
        Attribute::Integer
      end

      module Methods

        # Return a count aggregate function
        #
        # @example
        #   count = attribute.count
        #
        # @param [Attribute]
        #
        # @return [Count]
        #
        # @api public
        def count
          Count.new(self)
        end

      end # module Methods
    end # class Count
  end # class Aggregate
end # module Axiom

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.0 lib/axiom/aggregate/count.rb