Class: Yardstick::Rule

Inherits:
Object show all
Defined in:
lib/yardstick/rule.rb

Instance Method Summary collapse

Constructor Details

#initialize(description) { ... } ⇒ Rule

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a Rule instance

Parameters:

  • description (#to_str)

    the description of the Rule

Yields:

  • the measurement for the rule



16
17
18
19
# File 'lib/yardstick/rule.rb', line 16

def initialize(description, &block)
  @description = description.to_str
  @block       = block
end

Instance Method Details

#eql?(other) ⇒ Boolean

Test if Rule is equal to another rule

Examples:

rule == equal_rule  # => true

Parameters:

  • other (Rule)

    the other Rule

Returns:

  • (Boolean)

    true if the Rule is equal to the other, false if not



46
47
48
# File 'lib/yardstick/rule.rb', line 46

def eql?(other)
  @description.eql?(other.instance_variable_get(:@description))
end

#hashInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return hash identifier for the Rule

Returns:

  • (Integer)

    the hash identifier



56
57
58
# File 'lib/yardstick/rule.rb', line 56

def hash
  @description.hash
end

#measure(docstring) ⇒ Measurement

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a Measurement for a docstring

Parameters:

  • docstring (YARD::Docstring)

    the docstring to measure

Returns:



30
31
32
# File 'lib/yardstick/rule.rb', line 30

def measure(docstring)
  Measurement.new(@description, docstring, &@block)
end