Class: KalibroGatekeeperClient::Entities::Reading
- Defined in:
- lib/kalibro_gatekeeper_client/entities/reading.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#grade ⇒ Object
Returns the value of attribute grade.
-
#group_id ⇒ Object
Returns the value of attribute group_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
Attributes inherited from Model
Class 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
#color ⇒ Object
Returns the value of attribute color.
21 22 23 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 21 def color @color end |
#grade ⇒ Object
Returns the value of attribute grade.
21 22 23 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 21 def grade @grade end |
#group_id ⇒ Object
Returns the value of attribute group_id.
21 22 23 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 21 def group_id @group_id end |
#id ⇒ Object
Returns the value of attribute id.
21 22 23 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 21 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
21 22 23 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 21 def label @label end |
Class Method Details
.all ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 41 def self.all reading_groups = ReadingGroup.all readings = [] reading_groups.each do |reading_group| readings.concat(readings_of(reading_group.id)) end return readings end |
.exists?(id) ⇒ Boolean
51 52 53 54 55 56 57 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 51 def self.exists?(id) begin return true unless find(id).nil? rescue KalibroGatekeeperClient::Errors::RecordNotFound return false end end |
.find(id) ⇒ Object
31 32 33 34 35 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 31 def self.find(id) response = request('get', {id: id}) raise KalibroGatekeeperClient::Errors::RecordNotFound unless response['error'].nil? new response end |
.readings_of(group_id) ⇒ Object
37 38 39 |
# File 'lib/kalibro_gatekeeper_client/entities/reading.rb', line 37 def self.readings_of(group_id) create_objects_array_from_hash(request('of', {reading_group_id: group_id})['readings']) end |