Sha256: bff399beb6c3bf0a602c257a6a49bc52a3fa9a8c9ce82b68697cf17417287346

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

module Yardstick
  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

8 entries across 8 versions & 2 rubygems

Version Path
dkubb-yardstick-0.1.0 lib/yardstick/rule.rb
yardstick-0.7.0 lib/yardstick/rule.rb
yardstick-0.6.0 lib/yardstick/rule.rb
yardstick-0.5.0 lib/yardstick/rule.rb
yardstick-0.4.0 lib/yardstick/rule.rb
yardstick-0.3.0 lib/yardstick/rule.rb
yardstick-0.2.0 lib/yardstick/rule.rb
yardstick-0.1.0 lib/yardstick/rule.rb