Class: RubyUIConverter::FileWalker

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ui_converter/file_walker.rb

Overview

Finds .erb files under a path (recursively for directories).

Constant Summary collapse

ERB_GLOB =
"**/*.erb"

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileWalker

Returns a new instance of FileWalker.



8
9
10
# File 'lib/ruby_ui_converter/file_walker.rb', line 8

def initialize(path)
  @path = path
end

Instance Method Details

#erb_filesObject



12
13
14
15
16
17
18
19
20
# File 'lib/ruby_ui_converter/file_walker.rb', line 12

def erb_files
  if File.directory?(@path)
    Dir.glob(File.join(@path, ERB_GLOB)).select { |f| File.file?(f) }.sort
  elsif File.file?(@path) && @path.end_with?(".erb")
    [@path]
  else
    []
  end
end