Class: LearnParty::Student
- Inherits:
-
Object
- Object
- LearnParty::Student
- Defined in:
- lib/learn_party.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
Instance Method Summary collapse
- #generate_batch_students ⇒ Object
-
#initialize(collection) ⇒ Student
constructor
A new instance of Student.
- #student_hash_type ⇒ Object
- #student_instance_object_type ⇒ Object
Constructor Details
#initialize(collection) ⇒ Student
Returns a new instance of Student.
53 54 55 |
# File 'lib/learn_party.rb', line 53 def initialize(collection) @collection = collection end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
51 52 53 |
# File 'lib/learn_party.rb', line 51 def collection @collection end |
Instance Method Details
#generate_batch_students ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/learn_party.rb', line 57 def generate_batch_students if student_hash_type return collection.collect {|s| OpenStruct.new(s)} elsif student_instance_object_type return collection else raise StudentTypeError.new end end |
#student_hash_type ⇒ Object
67 68 69 |
# File 'lib/learn_party.rb', line 67 def student_hash_type collection.first.is_a?(Hash) && (collection.first.keys.include?("completed_lesson_count_for_active_track" || :completed_lesson_count_for_active_track)) end |
#student_instance_object_type ⇒ Object
71 72 73 |
# File 'lib/learn_party.rb', line 71 def student_instance_object_type collection.first.respond_to?(:completed_lesson_count_for_active_track) end |