Class: Logging::IO::File

Inherits:
Raw
  • Object
show all
Defined in:
lib/logging/io.rb

Overview

Write to a file.

Instance Attribute Summary collapse

Attributes inherited from Base

#label

Instance Method Summary collapse

Methods inherited from Raw

#write_multiple_messages, #write_single_message

Constructor Details

#initialize(label, path) ⇒ File

Returns a new instance of File.



50
51
52
# File 'lib/logging/io.rb', line 50

def initialize(label, path)
  @label, @path = label, path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



49
50
51
# File 'lib/logging/io.rb', line 49

def path
  @path
end

Instance Method Details

#fileObject



54
55
56
# File 'lib/logging/io.rb', line 54

def file
  @file ||= File.open(self.path, 'a')
end

#write(message) ⇒ Object



58
59
60
# File 'lib/logging/io.rb', line 58

def write(message)
  file.puts(message)
end