Class: Obcd::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/obcd/finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Finder

Returns a new instance of Finder.



5
6
7
8
# File 'lib/obcd/finder.rb', line 5

def initialize(path)
  @path = File.expand_path(path)
  fail Errno::ENOENT.new(path) unless File.exist?(@path) || Dir.exist?(@path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/obcd/finder.rb', line 3

def path
  @path
end

Instance Method Details

#find(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/obcd/finder.rb', line 10

def find(&block)
  if File.file?(path)
    yield path
  else
    Find.find(path) do |path|
      yield path if ['.h', '.m', '.pch'].include? File.extname(path)
    end
  end
end