Class: Questionaire
- Inherits:
-
Object
- Object
- Questionaire
- Defined in:
- lib/forgetful/questionaire.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #grade(results) ⇒ Object
-
#initialize(source) ⇒ Questionaire
constructor
A new instance of Questionaire.
- #questions ⇒ Object
Constructor Details
#initialize(source) ⇒ Questionaire
Returns a new instance of Questionaire.
4 5 6 |
# File 'lib/forgetful/questionaire.rb', line 4 def initialize(source) @source = source end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
2 3 4 |
# File 'lib/forgetful/questionaire.rb', line 2 def source @source end |
Instance Method Details
#grade(results) ⇒ Object
19 20 21 |
# File 'lib/forgetful/questionaire.rb', line 19 def grade(results) source.write(update(reminders, results)) end |
#questions ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/forgetful/questionaire.rb', line 8 def questions i = 0 reminders.map { |reminder| pair = [reminder, i]; i+=1; pair }. select { |reminder, i| reminder.due_on <= Date.today }. map do |reminder, i| { :id => i, :question => reminder.question, :answer => reminder.answer } end end |