Class: Hive::Results
- Inherits:
-
Object
- Object
- Hive::Results
- Defined in:
- lib/hive/results.rb
Instance Attribute Summary collapse
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #formulate_results ⇒ Object
-
#initialize(state, message, data = {}, hive_mind = nil) ⇒ Results
constructor
A new instance of Results.
- #passed? ⇒ Boolean
- #submit_results ⇒ Object
Constructor Details
#initialize(state, message, data = {}, hive_mind = nil) ⇒ Results
Returns a new instance of Results.
4 5 6 7 8 9 10 11 |
# File 'lib/hive/results.rb', line 4 def initialize( state, , data = {}, hive_mind=nil) @state = state = @data = data = Time.now @hive_mind = hive_mind submit_results end |
Instance Attribute Details
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/hive/results.rb', line 3 def end |
Instance Method Details
#failed? ⇒ Boolean
13 14 15 |
# File 'lib/hive/results.rb', line 13 def failed? @state == 'fail' end |
#formulate_results ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hive/results.rb', line 21 def formulate_results result = [] h = {} @data.each do |k,v| h[:label] = k.to_s h[:unit] = v[:unit] || nil if v[:value].instance_of?(Time) h[:value] = v[:value].to_i h[:format] = 'timestamp' else h[:value] = v[:value] h[:format] = 'integer' end result << h h = {} end result end |
#passed? ⇒ Boolean
17 18 19 |
# File 'lib/hive/results.rb', line 17 def passed? @state == 'pass' end |
#submit_results ⇒ Object
40 41 42 43 44 45 |
# File 'lib/hive/results.rb', line 40 def submit_results if @hive_mind @hive_mind.add_statistics(formulate_results) @hive_mind.flush_statistics end end |