Class: KalibroGatekeeperClient::Entities::BaseTool

Inherits:
Model
  • Object
show all
Defined in:
lib/kalibro_gatekeeper_client/entities/base_tool.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#kalibro_errors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

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

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, #save_action, #save_params

Constructor Details

This class inherits a constructor from KalibroGatekeeperClient::Entities::Model

Instance Attribute Details

#collector_class_nameObject

Returns the value of attribute collector_class_name.



22
23
24
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 22

def collector_class_name
  @collector_class_name
end

#descriptionObject

Returns the value of attribute description.



22
23
24
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 22

def description
  @description
end

#nameObject

Returns the value of attribute name.



22
23
24
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 22

def name
  @name
end

#supported_metricObject

Returns the value of attribute supported_metric.



22
23
24
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 22

def supported_metric
  @supported_metric
end

Class Method Details

.allObject



49
50
51
52
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 49

def self.all
  base_tools = all_names
  base_tools.map{ |name| find_by_name(name) }
end

.all_namesObject



44
45
46
47
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 44

def self.all_names
  # FIXME: for some reason, the JSON is not getting automatically parsed
  JSON.parse(request(:all_names, {}, :get))['base_tool_names'].to_a
end

.find_by_name(base_tool_name) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 36

def self.find_by_name(base_tool_name)
  begin
    new request(:get, {name: base_tool_name})
  rescue
    raise KalibroGatekeeperClient::Errors::RecordNotFound
  end
end

Instance Method Details

#metric(name) ⇒ Object



32
33
34
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 32

def metric(name)
  supported_metrics.find {|metric| metric.name == name}
end

#supported_metricsObject



28
29
30
# File 'lib/kalibro_gatekeeper_client/entities/base_tool.rb', line 28

def supported_metrics
  @supported_metric
end