class Deadlink::Path

Attributes

anchor[R]
cur_file_path[R]
index[R]

Public Class Methods

new(cur_file_path, link, index, repo_root) click to toggle source
# File lib/deadlink/path.rb, line 7
def initialize(cur_file_path, link, index, repo_root)
  @cur_file_path = cur_file_path
  @link = link
  @index = index
  @repo_root = repo_root
  
  hash = split_link(link)
  @anchor = hash[:anchor]
  @link_file_path = hash[:filepath]


  @abs_link_file_path = abs_link_file_path
end

Public Instance Methods

Private Instance Methods

anchor_invalid?(files) click to toggle source
# File lib/deadlink/path.rb, line 27
def anchor_invalid?(files)
  return false if @anchor.empty?

  # e.g [](#anchor)
  path =  only_anchor? ? @cur_file_path : @abs_link_file_path
  file = files.find_by(path)
  return !file.headers.include?(@anchor)
end
exist?() click to toggle source
# File lib/deadlink/path.rb, line 40
def exist?
  FileTest.exist?(@abs_link_file_path)
end
ignore?() click to toggle source
# File lib/deadlink/path.rb, line 62
def ignore?
  url?
end
not_exist?() click to toggle source

negative wrap

# File lib/deadlink/path.rb, line 72
def not_exist?
  !exist?
end
not_ignore?() click to toggle source
# File lib/deadlink/path.rb, line 76
def not_ignore?
  !ignore?
end
only_anchor?() click to toggle source
# File lib/deadlink/path.rb, line 36
def only_anchor?
  @link_file_path.empty? && !@anchor.empty? 
end
specify_root?(path) click to toggle source
# File lib/deadlink/path.rb, line 58
def specify_root?(path)
  path[0] == "/"
end
url?() click to toggle source
# File lib/deadlink/path.rb, line 66
def url?
  @link =~ /https?:\/\/[\S]+/
end