Class: Lita::Standups::Models::StandupResponse

Inherits:
Base
  • Object
show all
Includes:
Ohm::Callbacks, Ohm::DataTypes, Ohm::Timestamps
Defined in:
lib/lita/standups/models/standup_response.rb

Instance Method Summary collapse

Methods inherited from Base

redis

Instance Method Details

#after_saveObject



37
38
39
# File 'lib/lita/standups/models/standup_response.rb', line 37

def after_save
  standup_session.update_status if finished?
end

#before_createObject



33
34
35
# File 'lib/lita/standups/models/standup_response.rb', line 33

def before_create
  self.status ||= 'pending'
end

#finished?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/lita/standups/models/standup_response.rb', line 50

def finished?
  completed? || aborted? || expired?
end

#questionsObject



29
30
31
# File 'lib/lita/standups/models/standup_response.rb', line 29

def questions
  standup.questions
end

#report_messageObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/lita/standups/models/standup_response.rb', line 54

def report_message
  message = "#{user.name} (a.k.a @#{user.mention_name})\n"
  if answers.is_a?(Array)
    questions.map.with_index do |question, index|
      if answers[index]
        message << "> *#{question}*\n"
        answers[index].split("\n").each do |line|
          message << "> #{line}\n"
        end
      end
      message << "> \n" if index < questions.count - 1
    end
  else
    message << "> *Expired*\n"
  end
  message
end

#standupObject



25
26
27
# File 'lib/lita/standups/models/standup_response.rb', line 25

def standup
  standup_session.standup
end

#userObject



21
22
23
# File 'lib/lita/standups/models/standup_response.rb', line 21

def user
  @user ||= Lita::User.fuzzy_find(user_id)
end