Class: Obcd::Finder
- Inherits:
-
Object
- Object
- Obcd::Finder
- Defined in:
- lib/obcd/finder.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #find(&block) ⇒ Object
-
#initialize(path) ⇒ Finder
constructor
A new instance of Finder.
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.(path) fail Errno::ENOENT.new(path) unless File.exist?(@path) || Dir.exist?(@path) end |
Instance Attribute Details
#path ⇒ Object (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 |