Module: Safubot::Problematic
Overview
A mixin adding Problem handling.
Instance Method Summary collapse
-
#add_problem(e) ⇒ Object
Adds a timestamped Problem to the list.
-
#last_problem ⇒ Object
Fetches the most recent Problem.
Instance Method Details
#add_problem(e) ⇒ Object
Adds a timestamped Problem to the list.
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_problem ⇒ Object
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 |