Class: EacFs::Logs

Inherits:
Object show all
Defined in:
lib/eac_fs/logs.rb,
lib/eac_fs/logs/file.rb

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Instance Method Details

#[](label) ⇒ EacRubyUtils::Fs::Temp::File

Parameters:

  • label (Symbol)

Returns:

  • (EacRubyUtils::Fs::Temp::File)


13
14
15
# File 'lib/eac_fs/logs.rb', line 13

def [](label)
  log_set.fetch(sanitize_label(label)).file
end

#add(label) ⇒ EacFs::Logs

Parameters:

  • label (Symbol)

Returns:



19
20
21
22
23
24
# File 'lib/eac_fs/logs.rb', line 19

def add(label)
  file = ::EacFs::Logs::File.new(sanitize_label(label))
  log_set[file.label] = file

  self
end

#clean_allEacFs::Logs

Returns:



27
28
29
# File 'lib/eac_fs/logs.rb', line 27

def clean_all
  log_set.each_value(&:clean)
end

#remove(label) ⇒ Object

Parameters:

  • label (Symbol)


39
40
41
42
# File 'lib/eac_fs/logs.rb', line 39

def remove(label)
  log_set.fetch(sanitize_label(label)).remove
  log_set.delete(sanitize_label(label))
end

#remove_allEacFs::Logs

Returns:



32
33
34
35
36
# File 'lib/eac_fs/logs.rb', line 32

def remove_all
  log_set.each_key { |label| remove(label) }

  self
end

#truncate_all(length = ::EacFs::Logs::File::TRUNCATE_DEFAULT_LENGTH) ⇒ String

Parameters:

  • length (Integer) (defaults to: ::EacFs::Logs::File::TRUNCATE_DEFAULT_LENGTH)

Returns:

  • (String)


46
47
48
49
# File 'lib/eac_fs/logs.rb', line 46

def truncate_all(length = ::EacFs::Logs::File::TRUNCATE_DEFAULT_LENGTH)
  "Files: #{log_set.length}\n" +
    log_set.values.map { |file| file.truncate_with_label(length) }.join
end