Class: Fetchers::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/fetchers/local.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Local

Returns a new instance of Local.



17
18
19
20
21
22
23
# File 'lib/fetchers/local.rb', line 17

def initialize(target)
  if File.file?(target)
    @files = [target]
  else
    @files = Dir[File.join(target, '**', '*')]
  end
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



10
11
12
# File 'lib/fetchers/local.rb', line 10

def files
  @files
end

Class Method Details

.resolve(target) ⇒ Object



12
13
14
15
# File 'lib/fetchers/local.rb', line 12

def self.resolve(target)
  return nil unless File.exist?(target)
  new(target)
end

Instance Method Details

#read(file) ⇒ Object



25
26
27
28
29
# File 'lib/fetchers/local.rb', line 25

def read(file)
  return nil unless files.include?(file)
  return nil unless File.file?(file)
  File.read(file)
end