class PhisherPhinder::BodyHyperlink
Attributes
href[R]
raw_href[R]
text[R]
type[R]
Public Class Methods
new(href, text)
click to toggle source
# File lib/phisher_phinder/body_hyperlink.rb, line 7 def initialize(href, text) @type = classify_href(href.strip) @raw_href = href @href = parse_href(href) @text = text end
Public Instance Methods
==(other)
click to toggle source
# File lib/phisher_phinder/body_hyperlink.rb, line 18 def ==(other) href == other.href && text == other.text end
supports_retrieval?()
click to toggle source
# File lib/phisher_phinder/body_hyperlink.rb, line 14 def supports_retrieval? @type == :url && href.is_a?(URI) end
Private Instance Methods
classify_href(href_value)
click to toggle source
# File lib/phisher_phinder/body_hyperlink.rb, line 24 def classify_href(href_value) case href_value when /\A#/ :url_fragment when /\Amailto:/ :email_address when /\Atel:/ :telephone_number else :url end end
parse_href(href)
click to toggle source
# File lib/phisher_phinder/body_hyperlink.rb, line 37 def parse_href(href) stripped_href = href.strip (@type == :url && !stripped_href.empty?) ? URI.parse(strip_off_fragments(stripped_href)) : stripped_href end
strip_off_fragments(uri)
click to toggle source
# File lib/phisher_phinder/body_hyperlink.rb, line 43 def strip_off_fragments(uri) uri.split('#').first end