Class: Questionaire

Inherits:
Object
  • Object
show all
Defined in:
lib/forgetful/questionaire.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#sourceObject (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

#questionsObject



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