Class: Yardstick::Measurement
- Inherits:
-
Object
- Object
- Yardstick::Measurement
- Defined in:
- lib/yardstick/measurement.rb
Overview
A measurement given a constraint on the docs
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.
-
#puts(io = $stdout) ⇒ undefined
Warns the results the measurement if it was not successful.
-
#skip? ⇒ Boolean
Return true if the measurement was skipped.
-
#todo? ⇒ Boolean
Return true if the measurement is not implemented.
Constructor Details
#initialize(description, docstring) { ... } ⇒ Yardstick::Measurement
Return a Measurement instance
34 35 36 37 38 39 |
# File 'lib/yardstick/measurement.rb', line 34 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
15 16 17 |
# File 'lib/yardstick/measurement.rb', line 15 def description @description end |
Instance Method Details
#eql?(other) ⇒ Boolean
Test if Measurement is equal to another measurement
118 119 120 121 |
# File 'lib/yardstick/measurement.rb', line 118 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
129 130 131 |
# File 'lib/yardstick/measurement.rb', line 129 def hash [ @description, @docstring ].hash end |
#ok? ⇒ Boolean
Return true if the measurement was successful
53 54 55 |
# File 'lib/yardstick/measurement.rb', line 53 def ok? @result == true || skip? end |
#puts(io = $stdout) ⇒ undefined
Warns the results the measurement if it was not successful
100 101 102 103 104 |
# File 'lib/yardstick/measurement.rb', line 100 def puts(io = $stdout) unless ok? io.puts("#{file}:#{line}: #{path}: #{@description}") end end |
#skip? ⇒ Boolean
Return true if the measurement was skipped
69 70 71 |
# File 'lib/yardstick/measurement.rb', line 69 def skip? @result == :skip end |
#todo? ⇒ Boolean
Return true if the measurement is not implemented
85 86 87 |
# File 'lib/yardstick/measurement.rb', line 85 def todo? @result == :todo end |