Module: Safubot::Problematic

Included in:
Request, Response
Defined in:
lib/safubot/bot.rb

Overview

A mixin adding Problem handling.

Instance Method Summary collapse

Instance Method Details

#add_problem(e) ⇒ Object

Adds a timestamped Problem to the list.

Parameters:

  • e

    Exception from which the Problem is derived.



27
28
29
30
31
# File 'lib/safubot/bot.rb', line 27

def add_problem(e)
  problem = Problem.new(:error => e.to_s, :type => e.class.to_s,
						 :when => Time.now, :backtrace => e.backtrace)
  self.problems.push(problem)
end

#last_problemObject

Fetches the most recent Problem.



35
36
37
# File 'lib/safubot/bot.rb', line 35

def last_problem
  self.problems.sort { |x,y| x.when <=> y.when }.last
end