Sha256: 743fe5415b4b5f930f1eec3dc4b97b7a2a6fad901fbbf38dc46904d350da4cfb

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

module Axiom
  class Function
    class Numeric

      # A class representing a modulo function
      class Modulo < Numeric
        include Comparable, Binary

        # Return the Modulo operation
        #
        # @example
        #   Modulo.operation  # => :%
        #
        # @return [Symbol]
        #
        # @api public
        def self.operation
          :%
        end

        module Methods
          extend Aliasable

          inheritable_alias(
            :%   => :modulo,
            mod: :modulo
          )

          # Return a modulo function
          #
          # @example
          #   modulo = attribute.modulo(other)
          #
          # @param [Object] other
          #
          # @return [Modulo]
          #
          # @api public
          def modulo(other)
            Modulo.new(self, other)
          end

        end # module Methods

        Attribute::Numeric.class_eval { include Methods }
        Numeric.class_eval            { include Methods }

      end # class Modulo
    end # class Numeric
  end # class Function
end # module Axiom

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 lib/axiom/function/numeric/modulo.rb
axiom-0.1.1 lib/axiom/function/numeric/modulo.rb