class SiteChecker::Link

Attributes

kind[RW]
location[RW]
modified_url[RW]
parent_url[RW]
problem[RW]
url[RW]

Public Class Methods

create(attrs) click to toggle source
# File lib/site_checker/link.rb, line 22
def self.create(attrs)
  link = Link.new
  attrs.each do |key, value|
    if self.instance_methods.map{|m| m.to_s}.include?("#{key}=")
      eval("link.#{key}=value")
    end
  end
  link
end

Public Instance Methods

==(other) click to toggle source
# File lib/site_checker/link.rb, line 14
def ==(other)
  eql?(other)
end
anchor?() click to toggle source
# File lib/site_checker/link.rb, line 54
def anchor?
  @kind == :anchor
end
anchor_ref?() click to toggle source
# File lib/site_checker/link.rb, line 58
def anchor_ref?
  @kind == :anchor_ref
end
eql?(other) click to toggle source
# File lib/site_checker/link.rb, line 10
def eql?(other)
  @modified_url.eql? other.modified_url
end
has_problem?() click to toggle source
# File lib/site_checker/link.rb, line 42
def has_problem?
  @problem != nil
end
hash() click to toggle source
# File lib/site_checker/link.rb, line 18
def hash
  @modified_url.hash
end
local_image?() click to toggle source
# File lib/site_checker/link.rb, line 50
def local_image?
  @location == :local && @kind == :image
end
local_page?() click to toggle source
# File lib/site_checker/link.rb, line 46
def local_page?
  @location == :local && @kind == :page
end
parent_url=(parent_url) click to toggle source
# File lib/site_checker/link.rb, line 32
def parent_url=(parent_url)
  @modified_url = "#{parent_url}##{@url}" if anchor?
  @parent_url = parent_url
end
url=(url) click to toggle source
# File lib/site_checker/link.rb, line 37
def url=(url)
  @modified_url = ignore_trailing_slash(url)
  @url = url
end

Private Instance Methods

ignore_trailing_slash(url) click to toggle source
# File lib/site_checker/link.rb, line 67
def ignore_trailing_slash(url)
  url.gsub(/^\//,"")
end