Class: FileScheduler::Base

Inherits:
Object show all
Defined in:
lib/file_scheduler/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/file_scheduler/base.rb', line 6

def initialize(attributes = {})
  case attributes
  when String
    attributes = 
      { (attributes.url? ? :playlist : :directory) => attributes }
  when Pathname
    attributes = { :directory => attributes }
  end

  @root =
    if attributes.has_key?(:directory)
      FileScheduler::File.new(attributes[:directory])
    elsif attributes.has_key?(:playlist)
      FileScheduler::Playlist.new(attributes[:playlist])
    end
end

Instance Attribute Details

#logObject

Returns the value of attribute log.



4
5
6
# File 'lib/file_scheduler/base.rb', line 4

def log
  @log
end

#rootObject

Returns the value of attribute root.



4
5
6
# File 'lib/file_scheduler/base.rb', line 4

def root
  @root
end

#status_fileObject

Returns the value of attribute status_file.



4
5
6
# File 'lib/file_scheduler/base.rb', line 4

def status_file
  @status_file
end

Instance Method Details

#after_next(content) ⇒ Object



47
48
49
# File 'lib/file_scheduler/base.rb', line 47

def after_next(content)
  log.save(status_file) if status_file
end

#contentsObject



29
30
31
# File 'lib/file_scheduler/base.rb', line 29

def contents
  root.contents
end

#forced_next(time = Time.now) ⇒ Object



43
44
45
# File 'lib/file_scheduler/base.rb', line 43

def forced_next(time = Time.now)
  scheduling(time).forced_next
end

#next(time = Time.now) ⇒ Object



39
40
41
# File 'lib/file_scheduler/base.rb', line 39

def next(time = Time.now)
  scheduling(time).next
end

#scheduling(time = Time.now) ⇒ Object



33
34
35
36
37
# File 'lib/file_scheduler/base.rb', line 33

def scheduling(time = Time.now)
  Scheduling.new(root, time).tap do |scheduling|
    scheduling.log = log
  end
end