Class: Fetchers::Local
- Inherits:
-
Object
- Object
- Fetchers::Local
- Defined in:
- lib/fetchers/local.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(target) ⇒ Local
constructor
A new instance of Local.
- #read(file) ⇒ Object
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
#files ⇒ Object (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 |