Class: FileFeeder

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ruby_diff/file_feeder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileFeeder

Expects something in the form of PATH

--file [PATH]


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ruby_diff/file_feeder.rb', line 9

def initialize(path)
  @path = path
  
  if path =~ /^\s+$/
    @file_pattern = "**/*.rb"
  elsif File.file? path
    @file_pattern = path
  else
    @file_pattern = File.join(path, "**/*.rb")
  end
  @files = Dir[@file_pattern]
end

Instance Attribute Details

#filesObject

Returns the value of attribute files.



2
3
4
# File 'lib/ruby_diff/file_feeder.rb', line 2

def files
  @files
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/ruby_diff/file_feeder.rb', line 3

def path
  @path
end

Instance Method Details

#eachObject



22
23
24
25
26
# File 'lib/ruby_diff/file_feeder.rb', line 22

def each
  @files.each do |file|
    yield(open(file, 'r'){|io| io.read})      
  end
end