Class: QuickExam::RecordCollection
- Defined in:
- lib/quick_exam/record_collection.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#initialize(records = []) ⇒ RecordCollection
constructor
A new instance of RecordCollection.
- #mixes(count, shuffle_question: true, shuffle_answer: false, same_answer: false) ⇒ Object
Constructor Details
#initialize(records = []) ⇒ RecordCollection
Returns a new instance of RecordCollection.
5 6 7 |
# File 'lib/quick_exam/record_collection.rb', line 5 def initialize(records = []) @records = records end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
3 4 5 |
# File 'lib/quick_exam/record_collection.rb', line 3 def records @records end |
Instance Method Details
#mixes(count, shuffle_question: true, shuffle_answer: false, same_answer: false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/quick_exam/record_collection.rb', line 9 def mixes(count, shuffle_question: true, shuffle_answer: false, same_answer: false) @records = self @same_answer = same_answer return records if count.zero? count.times.each_with_object([]) do |_, memo| new_records = records.dup new_records.shuffle! if shuffle_question shuffle_answers(new_records) if shuffle_answer memo << new_records end end |