Class: MailProvider::SourceManager

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_provider/source_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, directory = nil) ⇒ SourceManager

Returns a new instance of SourceManager.



7
8
9
10
11
# File 'lib/mail_provider/source_manager.rb', line 7

def initialize(path = nil, directory = nil)
  @path = path || File.join(MailProvider::ROOT_DIR, 'sources.txt')
  @directory = directory || File.join(MailProvider::ROOT_DIR, 'sources')
  @missing = unavailable_sources
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



5
6
7
# File 'lib/mail_provider/source_manager.rb', line 5

def directory
  @directory
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/mail_provider/source_manager.rb', line 5

def path
  @path
end

#totalObject (readonly)

Returns the value of attribute total.



5
6
7
# File 'lib/mail_provider/source_manager.rb', line 5

def total
  @total
end

Instance Method Details

#run(refresh: false) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/mail_provider/source_manager.rb', line 13

def run(refresh: false)
  @missing = refresh ? sources : unavailable_sources
  download
  save

  sources # fetch sources again to update total count
end