Class: KalibroGem::Entities::ModuleResult

Inherits:
Model
  • Object
show all
Defined in:
lib/kalibro_gem/entities/module_result.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, #errors=, exists?, #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 KalibroGem::Entities::Model

Instance Attribute Details

#gradeObject

Returns the value of attribute grade.



23
24
25
# File 'lib/kalibro_gem/entities/module_result.rb', line 23

def grade
  @grade
end

#heightObject

Returns the value of attribute height.



23
24
25
# File 'lib/kalibro_gem/entities/module_result.rb', line 23

def height
  @height
end

#idObject

Returns the value of attribute id.



23
24
25
# File 'lib/kalibro_gem/entities/module_result.rb', line 23

def id
  @id
end

#moduleObject

Returns the value of attribute module.



23
24
25
# File 'lib/kalibro_gem/entities/module_result.rb', line 23

def module
  @module
end

#parent_idObject

Returns the value of attribute parent_id.



23
24
25
# File 'lib/kalibro_gem/entities/module_result.rb', line 23

def parent_id
  @parent_id
end

Class Method Details

.find(id) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/kalibro_gem/entities/module_result.rb', line 25

def self.find(id)
  begin
    new request(:get_module_result, { :module_result_id => id })[:module_result]
  rescue Savon::SOAPFault
    raise KalibroGem::Errors::RecordNotFound
  end
end

.history_of(module_result_id) ⇒ Object



71
72
73
74
# File 'lib/kalibro_gem/entities/module_result.rb', line 71

def self.history_of(module_result_id)
  response = self.create_array_from_hash self.request(:history_of_module, {:module_result_id => module_result_id})[:date_module_result]
  response.map {|date_module_result| KalibroGem::Entities::DateModuleResult.new date_module_result}
end

Instance Method Details

#childrenObject



33
34
35
36
# File 'lib/kalibro_gem/entities/module_result.rb', line 33

def children
  response = self.class.request(:children_of, {:module_result_id => id})[:module_result]
  self.class.create_objects_array_from_hash(response)
end

#file?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/kalibro_gem/entities/module_result.rb', line 67

def file?
  !self.folder?
end

#folder?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/kalibro_gem/entities/module_result.rb', line 63

def folder?
  self.children.count > 0
end

#parentsObject



38
39
40
41
42
43
44
45
# File 'lib/kalibro_gem/entities/module_result.rb', line 38

def parents
  if parent_id == 0
    []
  else
    parent = self.class.find(parent_id)
    parent.parents << parent
  end
end