Class: KalibroGatekeeperClient::Entities::Range
- Defined in:
- lib/kalibro_gatekeeper_client/entities/range.rb
Instance Attribute Summary collapse
-
#beginning ⇒ Object
Returns the value of attribute beginning.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#end ⇒ Object
Returns the value of attribute end.
-
#id ⇒ Object
Returns the value of attribute id.
-
#metric_configuration_id ⇒ Object
Returns the value of attribute metric_configuration_id.
-
#reading_id ⇒ Object
Returns the value of attribute reading_id.
Attributes inherited from Model
Class Method Summary collapse
- .all ⇒ Object
- .exists?(id) ⇒ Boolean
- .find(id) ⇒ Object
- .ranges_of(metric_configuration_id) ⇒ Object
Instance Method Summary collapse
Methods inherited from Model
#==, create, create_array_from_hash, create_objects_array_from_hash, #destroy, #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
Constructor Details
This class inherits a constructor from KalibroGatekeeperClient::Entities::Model
Instance Attribute Details
#beginning ⇒ Object
Returns the value of attribute beginning.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 23 def beginning @beginning end |
#comments ⇒ Object
Returns the value of attribute comments.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 23 def comments @comments end |
#end ⇒ Object
Returns the value of attribute end.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 23 def end @end end |
#id ⇒ Object
Returns the value of attribute id.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 23 def id @id end |
#metric_configuration_id ⇒ Object
Returns the value of attribute metric_configuration_id.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 23 def metric_configuration_id @metric_configuration_id end |
#reading_id ⇒ Object
Returns the value of attribute reading_id.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 23 def reading_id @reading_id end |
Class Method Details
.all ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 57 def self.all metric_configurations = [] ranges = [] configurations = Configuration.all configurations.each do |config| metric_configurations.concat(MetricConfiguration.metric_configurations_of(config.id)) end metric_configurations.each do |metric_config| ranges.concat(self.ranges_of(metric_config.id)) end return ranges end |
.exists?(id) ⇒ Boolean
80 81 82 83 84 85 86 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 80 def self.exists?(id) begin return true unless self.find(id).nil? rescue KalibroGatekeeperClient::Errors::RecordNotFound return false end end |
.find(id) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 73 def self.find(id) self.all.each do |range| return range if range.id == id end raise KalibroGatekeeperClient::Errors::RecordNotFound end |
.ranges_of(metric_configuration_id) ⇒ Object
53 54 55 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 53 def self.ranges_of(metric_configuration_id) self.create_objects_array_from_hash request('of', {metric_configuration_id: metric_configuration_id} )['ranges'] end |
Instance Method Details
#color ⇒ Object
49 50 51 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 49 def color reading.color end |
#grade ⇒ Object
45 46 47 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 45 def grade reading.grade end |
#label ⇒ Object
41 42 43 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 41 def label reading.label end |
#reading ⇒ Object
88 89 90 91 |
# File 'lib/kalibro_gatekeeper_client/entities/range.rb', line 88 def reading @reading ||= KalibroGatekeeperClient::Entities::Reading.find(reading_id) @reading end |