Class: Yardstick::Measurement
Defined Under Namespace
Modules: UtilityMethods
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
Return the Measurement description.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
Test if Measurement is equal to another measurement.
-
#hash ⇒ Integer
private
Return hash identifier for the Measurement.
-
#initialize(description, docstring) { ... } ⇒ Yardstick::Measurement
constructor
Return a Measurement instance.
-
#ok? ⇒ Boolean
Return true if the measurement was successful.
-
#skip? ⇒ Boolean
Return true if the measurement was skipped.
-
#todo? ⇒ Boolean
Return true if the measurement is not implemented.
-
#warn ⇒ undefined
Warns the results the measurement if it was not successful.
Constructor Details
#initialize(description, docstring) { ... } ⇒ Yardstick::Measurement
Return a Measurement instance
32 33 34 35 36 37 |
# File 'lib/yardstick/measurement.rb', line 32 def initialize(description, docstring, &block) @description = description.to_str @docstring = docstring @block = block @result = measure end |
Instance Attribute Details
#description ⇒ String (readonly)
Return the Measurement description
13 14 15 |
# File 'lib/yardstick/measurement.rb', line 13 def description @description end |
Instance Method Details
#eql?(other) ⇒ Boolean
Test if Measurement is equal to another measurement
113 114 115 116 |
# File 'lib/yardstick/measurement.rb', line 113 def eql?(other) @description.eql?(other.instance_variable_get(:@description)) && @docstring.eql?(other.instance_variable_get(:@docstring)) end |
#hash ⇒ Integer
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 Measurement
124 125 126 |
# File 'lib/yardstick/measurement.rb', line 124 def hash [ @description, @docstring ].hash end |
#ok? ⇒ Boolean
Return true if the measurement was successful
51 52 53 |
# File 'lib/yardstick/measurement.rb', line 51 def ok? @result == true || skip? end |
#skip? ⇒ Boolean
Return true if the measurement was skipped
67 68 69 |
# File 'lib/yardstick/measurement.rb', line 67 def skip? @result == :skip end |
#todo? ⇒ Boolean
Return true if the measurement is not implemented
83 84 85 |
# File 'lib/yardstick/measurement.rb', line 83 def todo? @result == :todo end |
#warn ⇒ undefined
Warns the results the measurement if it was not successful
95 96 97 98 99 |
# File 'lib/yardstick/measurement.rb', line 95 def warn unless ok? Kernel.warn("#{file}:#{line}: #{path}: #{@description}") end end |