Class: Semlogger::Rotate
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #close ⇒ Object
- #filename ⇒ Object
-
#initialize(filename) ⇒ Rotate
constructor
A new instance of Rotate.
- #open_if ⇒ Object
- #write(message) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Rotate
Returns a new instance of Rotate.
6 7 8 |
# File 'lib/semlogger/rotate.rb', line 6 def initialize filename @filename = filename end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
2 3 4 |
# File 'lib/semlogger/rotate.rb', line 2 def file @file end |
Instance Method Details
#close ⇒ Object
21 22 23 24 |
# File 'lib/semlogger/rotate.rb', line 21 def close @file.close @file = nil end |
#filename ⇒ Object
4 |
# File 'lib/semlogger/rotate.rb', line 4 def filename() @filename.dup end |
#open_if ⇒ Object
10 11 12 13 14 15 |
# File 'lib/semlogger/rotate.rb', line 10 def open_if name = Time.now.strftime( @filename).gsub /%\$/, $$.to_s close if @file and name != @file.path @file = File.open name, 'a' unless @file @file end |
#write(message) ⇒ Object
17 18 19 |
# File 'lib/semlogger/rotate.rb', line 17 def write open_if.write end |