Class: Perfer::Result
- Inherits:
-
Object
- Object
- Perfer::Result
- Extended by:
- Forwardable
- Defined in:
- lib/perfer/result.rb
Overview
A result for a particular job run
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(metadata, data = []) ⇒ Result
constructor
A new instance of Result.
- #on(field) ⇒ Object
- #stats ⇒ Object
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(metadata, data = []) ⇒ Result
Returns a new instance of Result.
8 9 10 11 |
# File 'lib/perfer/result.rb', line 8 def initialize(, data = []) @metadata = .dup @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/perfer/result.rb', line 7 def data @data end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/perfer/result.rb', line 6 def @metadata end |
Class Method Details
.json_create(json) ⇒ Object
38 39 40 |
# File 'lib/perfer/result.rb', line 38 def self.json_create json new(json['metadata'], json['data']) end |
Instance Method Details
#on(field) ⇒ Object
22 23 24 |
# File 'lib/perfer/result.rb', line 22 def on(field) @data.map { |result| result[field] } end |
#stats ⇒ Object
18 19 20 |
# File 'lib/perfer/result.rb', line 18 def stats Statistics.new(on(:real)) end |
#to_hash ⇒ Object
26 27 28 |
# File 'lib/perfer/result.rb', line 26 def to_hash { :metadata => @metadata, :data => @data } end |
#to_json(*args) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/perfer/result.rb', line 30 def to_json(*args) { 'json_class' => self.class.name, 'data' => @data, 'metadata' => @metadata }.to_json(*args) end |