[#4595] New block syntax — Daniel Amelang <daniel.amelang@...>

I'm really sorry if this isn't the place to talk about this. I've

25 messages 2005/03/21
[#4606] Re: New block syntax — "David A. Black" <dblack@...> 2005/03/21

Hi --

[#4629] Re: New block syntax — "Sean E. Russell" <ser@...> 2005/03/30

On Monday 21 March 2005 16:17, David A. Black wrote:

[#4648] about REXML::Encoding — speakillof <speakillof@...>

Hi.

15 messages 2005/03/31
[#4659] Re: about REXML::Encoding — "Sean E. Russell" <ser@...> 2005/04/04

On Thursday 31 March 2005 09:44, speakillof wrote:

[patch] logger.rb - allowing logger to be innitialized in a single line

From: Sam Roberts <sroberts@...>
Date: 2005-03-09 20:57:02 UTC
List: ruby-core #4542
I wanted to do:

   SomeClass.logger = Logger.new(name, shift_age = 'weekly') { |l| l.level = Logger::ERROR }

not

   alogger = Logger.new(name, shift_age = 'weekly')
   alogger.level = Logger::ERROR
   SomeClass.logger = alogger


Index: lib/logger.rb
===================================================================
RCS file: /src/ruby/lib/logger.rb,v
retrieving revision 1.5.2.4
diff -u -r1.5.2.4 logger.rb
--- lib/logger.rb 27 May 2004 14:39:11 -0000  1.5.2.4
+++ lib/logger.rb 9 Mar 2005 20:38:29 -0000
@@ -229,6 +229,7 @@
   #
   #   Logger.new(name, shift_age = 7, shift_size = 1048576)
   #   Logger.new(name, shift_age = 'weekly')
+  #   Logger.new(name, shift_age = 'weekly') { |l| l.level = Logger::ERROR }
   #
   # === Args
   # 
@@ -246,7 +247,7 @@
   # Create an instance.  See Logger::LogDevice.new for more information if
   # required.
   # 
-  def initialize(logdev, shift_age = 0, shift_size = 1048576)
+  def initialize(logdev, shift_age = 0, shift_size = 1048576, &proc)
     @logdev = nil
     @progname = nil
     @level = DEBUG
@@ -255,6 +256,7 @@
     if logdev
       @logdev = LogDevice.new(logdev, :shift_age => shift_age, :shift_size => shift_size)
     end
+    proc.call(self) if proc
   end
 
   # 


In This Thread

Prev Next