Class: Logs

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/docfolio/docfolio.rb

Overview

collection class for Learning Diarys / logs

Instance Method Summary collapse

Constructor Details

#initialize(loading_logs = true) ⇒ Logs

iterates through every file in the data directory and parses with

LearningDiary


11
12
13
14
15
16
17
18
# File 'lib/docfolio/docfolio.rb', line 11

def initialize(loading_logs = true)
  @logs = []
  if loading_logs
    log_files_dir.each do |log_file_name|
      @logs << LearningDiary.new(log_file_name)
    end
  end
end

Instance Method Details

#add(file_or_directory) ⇒ Object

Adds either a file to logs or a directory to logs

Parameters:

  • A string containing the name of a file or directory



23
24
25
26
# File 'lib/docfolio/docfolio.rb', line 23

def add(file_or_directory)
  log_directory(file_or_directory) if File.directory?(file_or_directory)
  log_file(file_or_directory) if File.file?(file_or_directory)
end

#each(&block) ⇒ Object



28
29
30
# File 'lib/docfolio/docfolio.rb', line 28

def each(&block)
  @logs.each { |p| block.call(p) }
end