Class: Pmux::Joblogger
- Inherits:
-
Object
- Object
- Pmux::Joblogger
- Defined in:
- lib/pmux/joblogger.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add(key, obj) ⇒ Object
- #close ⇒ Object
- #dump(obj) ⇒ Object
- #dump_footer ⇒ Object
- #dump_header ⇒ Object
-
#initialize(dir, job) ⇒ Joblogger
constructor
A new instance of Joblogger.
- #sep ⇒ Object
Constructor Details
#initialize(dir, job) ⇒ Joblogger
Returns a new instance of Joblogger.
7 8 9 10 11 12 13 14 |
# File 'lib/pmux/joblogger.rb', line 7 def initialize dir, job @dir = dir @job = job if dir and File.directory? dir @path = "#{dir}/#{job.id}.yml" @f = open(@path, 'w') end end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/pmux/joblogger.rb', line 5 def path @path end |
Instance Method Details
#add(key, obj) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/pmux/joblogger.rb', line 34 def add key, obj return unless @f @f.puts "#{key}:" for k, v in obj @f.puts " #{k}: #{v.inspect}" end end |
#close ⇒ Object
42 43 44 |
# File 'lib/pmux/joblogger.rb', line 42 def close @f.close if @f end |
#dump(obj) ⇒ Object
24 25 26 |
# File 'lib/pmux/joblogger.rb', line 24 def dump obj @f.print YAML.dump(obj) if @f end |
#dump_footer ⇒ Object
20 21 22 |
# File 'lib/pmux/joblogger.rb', line 20 def dump @job. end |
#dump_header ⇒ Object
16 17 18 |
# File 'lib/pmux/joblogger.rb', line 16 def dump_header dump @job.to_jlheader end |
#sep ⇒ Object
28 29 30 31 32 |
# File 'lib/pmux/joblogger.rb', line 28 def sep return unless @f @f.puts '---' @f.flush end |