Sha256: 44f0bb54c49b8fce7559a1bedb72d0c2c3b34fa842455f000f8a2b5f5dc4b860

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

# encoding: utf-8

module Yardstick

  # A constraint on the docs
  class Rule

    # Return a Rule instance
    #
    # @param [#to_str] description
    #   the description of the Rule
    #
    # @yield []
    #   the measurement for the rule
    #
    # @return [Rule]
    #   the rule instance
    #
    # @api private
    def initialize(description, &block)
      @description = description.to_str
      @block       = block
    end

    # Return a Measurement for a docstring
    #
    # @param [YARD::Docstring] docstring
    #   the docstring to measure
    #
    # @return [Measurement]
    #   the measurement
    #
    # @api private
    def measure(docstring)
      Measurement.new(@description, docstring, &@block)
    end

    # Test if Rule is equal to another rule
    #
    # @example
    #   rule == equal_rule  # => true
    #
    # @param [Rule] other
    #   the other Rule
    #
    # @return [Boolean]
    #   true if the Rule is equal to the other, false if not
    #
    # @api semipublic
    def eql?(other)
      @description.eql?(other.instance_variable_get(:@description))
    end

    # Return hash identifier for the Rule
    #
    # @return [Integer]
    #   the hash identifier
    #
    # @api private
    def hash
      @description.hash
    end

  end # class Rule
end # module Yardstick

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yardstick-0.9.6 lib/yardstick/rule.rb
yardstick-0.9.5 lib/yardstick/rule.rb
yardstick-0.9.4 lib/yardstick/rule.rb
yardstick-0.9.3 lib/yardstick/rule.rb