# File lib/rbot/load-gettext.rb, line 136 def Nn_(s_single, s_plural) n_(s_single, s_plural) end
dummy functions that return msg_id without translation
# File lib/rbot/load-gettext.rb, line 124 def _(s) s end
# File lib/rbot/load-gettext.rb, line 144 def bindtextdomain_to(*args) end
# File lib/rbot/ircbot.rb, line 107 def debug(message=nil, who_pos=1) rawlog(Logger::Severity::DEBUG, message, who_pos) end
# File lib/rbot/ircbot.rb, line 119 def error(message=nil, who_pos=1) rawlog(Logger::Severity::ERROR, message, who_pos) end
# File lib/rbot/ircbot.rb, line 123 def fatal(message=nil, who_pos=1) rawlog(Logger::Severity::FATAL, message, who_pos) end
# File lib/rbot/ircbot.rb, line 72 def halt_logger if $log_thread && $log_thread.alive? $log_queue << nil $log_thread.join $log_thread = nil end end
# File lib/rbot/ircbot.rb, line 111 def log(message=nil, who_pos=1) rawlog(Logger::Severity::INFO, message, who_pos) end
# File lib/rbot/ircbot.rb, line 102 def log_session_end $logger << "\n\n=== #{botclass} session ended on #{Time.now.strftime($dateformat)} ===\n\n" $log_queue << nil end
# File lib/rbot/ircbot.rb, line 97 def log_session_start $logger << "\n\n=== #{botclass} session started on #{Time.now.strftime($dateformat)} ===\n\n" restart_logger end
# File lib/rbot/load-gettext.rb, line 132 def n_(s_single, s_plural, n) n > 1 ? s_plural : s_single end
We extend the Object class with a method that checks if the receiver is nil or empty
# File lib/rbot/irc.rb, line 43 def nil_or_empty? return true unless self return true if self.respond_to? :empty? and self.empty? return false end
# File lib/rbot/ircbot.rb, line 27 def pretty_inspect PP.pp(self, '') end
# File lib/rbot/ircbot.rb, line 47 def rawlog(level, message=nil, who_pos=1) call_stack = caller if call_stack.length > who_pos who = call_stack[who_pos].sub(%{(?:.+)/([^/]+):(\d+)(:in .*)?}) { "#{$1}:#{$2}#{$3}" } else who = "(unknown)" end # Output each line. To distinguish between separate messages and multi-line # messages originating at the same time, we blank #{who} after the first message # is output. # Also, we output strings as-is but for other objects we use pretty_inspect case message when String str = message else str = message.pretty_inspect end qmsg = Array.new str.each_line { |l| qmsg.push [level, l.chomp, who] who = ' ' * who.size } $log_queue.push qmsg end
# File lib/rbot/ircbot.rb, line 82 def restart_logger(newlogger = false) halt_logger $logger = newlogger if newlogger $log_thread = Thread.new do ls = nil while ls = $log_queue.pop ls.each { |l| $logger.add(*l) } end end end
Generated with the Darkfish Rdoc Generator 2.