Class: BadLinkFinder::Site

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bad_link_finder/site.rb

Instance Method Summary collapse

Constructor Details

#initialize(mirror_dir, start_from = nil) ⇒ Site

Returns a new instance of Site.



8
9
10
11
# File 'lib/bad_link_finder/site.rb', line 8

def initialize(mirror_dir, start_from = nil)
  @mirror_dir = mirror_dir.is_a?(String) ? Pathname.new(mirror_dir) : mirror_dir
  @start_from = start_from
end

Instance Method Details

#eachObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bad_link_finder/site.rb', line 13

def each
  Dir.chdir(@mirror_dir) do
    paths = Dir.glob('**/*').sort
    paths = paths[paths.index(@start_from)..-1] if @start_from

    paths.each do |path|
      next if File.directory?(path)
      yield BadLinkFinder::Page.new(@mirror_dir, path)
    end
  end
end