Class: Ralf::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/ralf/log.rb

Instance Method Summary collapse

Constructor Details

#initialize(key, targetprefix) ⇒ Log

Returns a new instance of Log.



3
4
5
6
# File 'lib/ralf/log.rb', line 3

def initialize(key, targetprefix)
  @key          = key
  @targetprefix = targetprefix
end

Instance Method Details

#nameObject



8
9
10
# File 'lib/ralf/log.rb', line 8

def name
  @key.name.gsub(@targetprefix, '')
end

#save_to_dir(dir, use_cache = true) ⇒ Object



12
13
14
15
16
# File 'lib/ralf/log.rb', line 12

def save_to_dir(dir, use_cache = true)
  file = File.join(dir, name)
  File.open(file, 'w') { |f| f.write(@key.data) } unless use_cache and File.exist?(file)
  file # return saved filename
end