Class: CallerLog::Log
- Inherits:
-
Object
- Object
- CallerLog::Log
- Defined in:
- lib/caller_log/log.rb
Defined Under Namespace
Classes: Html
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#lock ⇒ Object
readonly
Returns the value of attribute lock.
Instance Method Summary collapse
-
#initialize(file) ⇒ Log
constructor
A new instance of Log.
- #puts(record) ⇒ Object
Constructor Details
#initialize(file) ⇒ Log
Returns a new instance of Log.
12 13 14 15 16 17 |
# File 'lib/caller_log/log.rb', line 12 def initialize file file = File.new file, 'a+' unless File === file @file = file @html = Html.new @lock = Mutex.new end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
10 11 12 |
# File 'lib/caller_log/log.rb', line 10 def file @file end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
10 11 12 |
# File 'lib/caller_log/log.rb', line 10 def html @html end |
#lock ⇒ Object (readonly)
Returns the value of attribute lock.
10 11 12 |
# File 'lib/caller_log/log.rb', line 10 def lock @lock end |
Instance Method Details
#puts(record) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/caller_log/log.rb', line 19 def puts record lock.synchronize do html.add record File.open file, 'w+' do |f| f.puts html.to_s end end end |