Class: Mittsu::FileLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/mittsu/loaders/file_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(manager = nil) ⇒ FileLoader

Returns a new instance of FileLoader.



3
4
5
# File 'lib/mittsu/loaders/file_loader.rb', line 3

def initialize(manager = nil)
  @manager = manager || DefaultLoadingManager
end

Instance Method Details

#load(url) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mittsu/loaders/file_loader.rb', line 7

def load(url)
  cached = Cache.get(url)

  return cached unless cached.nil?

  @manager.item_start(url)

  text = File.read(url)
  Cache.add(url, text)

  @manager.item_end(url)

  text
end