Class: HDOC::Log
- Inherits:
-
Object
- Object
- HDOC::Log
- Defined in:
- lib/1hdoc/core/log.rb
Overview
Provides methods for interact with the log file.
Instance Attribute Summary collapse
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
Class Method Summary collapse
Instance Method Summary collapse
- #append(content) ⇒ Object
-
#initialize(log_path) ⇒ Log
constructor
A new instance of Log.
Constructor Details
#initialize(log_path) ⇒ Log
Returns a new instance of Log.
12 13 14 15 |
# File 'lib/1hdoc/core/log.rb', line 12 def initialize(log_path) @log_path = File.(log_path) raise Errno::ENOENT unless File.exist? log_path end |
Instance Attribute Details
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
5 6 7 |
# File 'lib/1hdoc/core/log.rb', line 5 def log_path @log_path end |
Class Method Details
.reset(log_path) ⇒ Object
7 8 9 10 |
# File 'lib/1hdoc/core/log.rb', line 7 def self.reset(log_path) log_path = File.(log_path) File.open(log_path, 'w') { |log| log.print '' } end |
Instance Method Details
#append(content) ⇒ Object
17 18 19 |
# File 'lib/1hdoc/core/log.rb', line 17 def append(content) File.open(log_path, 'a') { |log| log.puts content } end |