Class: KalibroClient::Entities::Processor::MetricResult

Inherits:
Base
  • Object
show all
Defined in:
lib/kalibro_client/entities/processor/metric_result.rb

Instance Attribute Summary collapse

Attributes included from DateAttributes

#created_at, #updated_at

Attributes inherited from Base

#kalibro_errors, #persisted

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

address

Methods inherited from Base

#==, create, create_array_from_hash, create_objects_array_from_hash, #destroy, exists?, find, request, #save, #save!, #to_hash, to_object, to_objects_array, #update

Methods included from RequestMethods::ClassMethods

#exists_action, #find_action, #id_params

Methods included from HashConverters

#convert_to_hash, #date_with_milliseconds, #field_to_hash

Methods included from XMLConverters

#get_xml, #xml_instance_class_name

Methods included from RequestMethods

#destroy_action, #destroy_params, #destroy_prefix, #save_action, #save_params, #save_prefix, #update_params, #update_prefix

Constructor Details

#initialize(attributes = {}, persisted = false) ⇒ MetricResult

Returns a new instance of MetricResult.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 25

def initialize(attributes={}, persisted=false)
  value = attributes["value"]
  @value = (value == "NaN") ? attributes["aggregated_value"].to_f : value.to_f
  attributes.each do |field, value|
    if field!= "value" and field!= "aggregated_value" and self.class.is_valid?(field)
      send("#{field}=", value)
    end
  end
  @kalibro_errors = []
  @persisted = persisted
end

Instance Attribute Details

#aggregated_valueObject

Returns the value of attribute aggregated_value.



22
23
24
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 22

def aggregated_value
  @aggregated_value
end

#idObject

Returns the value of attribute id.



22
23
24
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 22

def id
  @id
end

#metric_configurationObject

Returns the value of attribute metric_configuration.



23
24
25
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 23

def metric_configuration
  @metric_configuration
end

#metric_configuration_idObject

Returns the value of attribute metric_configuration_id.



22
23
24
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 22

def metric_configuration_id
  @metric_configuration_id
end

#module_result_idObject

Returns the value of attribute module_result_id.



22
23
24
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 22

def module_result_id
  @module_result_id
end

#valueObject

Returns the value of attribute value.



22
23
24
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 22

def value
  @value
end

Class Method Details

.history_of(metric_name, kalibro_module_id, repository_id) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 63

def self.history_of(metric_name, kalibro_module_id, repository_id)
  response = Repository.request(':id/metric_result_history_of', {metric_name: metric_name,
                                                kalibro_module_id: kalibro_module_id,
                                                id: repository_id})['metric_result_history_of']
  response.map { |date_metric_result|
    KalibroClient::Entities::Miscellaneous::DateMetricResult.new date_metric_result }
end

Instance Method Details

#descendant_valuesObject



58
59
60
61
# File 'lib/kalibro_client/entities/processor/metric_result.rb', line 58

def descendant_values
  descendant_values = self.class.request(':id/descendant_values', {id: id}, :get)['descendant_values']
  descendant_values.map {|descendant_value| descendant_value.to_f}
end