Class: Mangos::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/mangos/processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(package) ⇒ Processor

Returns a new instance of Processor.



2
3
4
5
# File 'lib/mangos/processor.rb', line 2

def initialize(package)
  @package = package
  @original_mtime = @package.data_path.exist? ? @package.data_path.mtime : 0
end

Instance Method Details

#create(path) ⇒ Object



7
8
9
# File 'lib/mangos/processor.rb', line 7

def create(path)
  Mangos::Book.new.tap { |book| Mangos::BookUpdater.new(@package, book, path).update }
end

#delete(book) ⇒ Object



24
25
# File 'lib/mangos/processor.rb', line 24

def delete(book)
end

#update(path, book) ⇒ Object



11
12
13
14
15
# File 'lib/mangos/processor.rb', line 11

def update(path, book)
  return false if !update?(path, book)
  Mangos::BookUpdater.new(@package, book, path).update
  true
end

#update?(path, book) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/mangos/processor.rb', line 17

def update?(path, book)
  return true if @package.force?
  return true if path.mtime >= @original_mtime
  return true if book.pages == 0
  false
end