Sha256: 13639827c8c181358139aa3354e930f0017b66c52fce604a5e3ccf19c877b438

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

module Yardstick
  module Measurable
    include Measurement::UtilityMethods

    module ClassMethods

      # Include the class or module with measurable class methods
      #
      # @param [Module] mod
      #   the module to include within
      #
      # @return [undefined]
      #
      # @api private
      def included(mod)
        mod.extend(ClassMethods).rules.merge(rules)
      end

      # List of rules for this class
      #
      # @return [Yardstick::RuleSet<Rule>]
      #   the rules for this class
      #
      # @api private
      def rules
        @rules ||= RuleSet.new
      end

      # Set the description for the rule
      #
      # @param [#to_str] description
      #   the rule description
      #
      # @yield []
      #   the rule to perform
      #
      # @yieldreturn [Boolean]
      #   return true if successful, false if not
      #
      # @return [undefined]
      #
      # @api private
      def rule(description, &block)
        rules << Rule.new(description, &block)
      end

    end # module ClassMethods

    extend ClassMethods

    # Return a list of measurements for this docstring instance
    #
    # @example
    #   docstring.measure  # => [ Measurement ]
    #
    # @return [Yardstick::MeasurementSet]
    #   a collection of measurements
    #
    # @api public
    def measure
      self.class.rules.measure(self)
    end

  end # module Measurable
end # module Yardstick

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yardstick-0.9.2 lib/yardstick/measurable.rb
yardstick-0.9.1 lib/yardstick/measurable.rb
yardstick-0.9.0 lib/yardstick/measurable.rb
yardstick-0.8.0 lib/yardstick/measurable.rb