Class: LinkPreview::ExternalFavicon

Inherits:
ExternalImage show all
Defined in:
lib/link_preview/external_favicon.rb

Instance Attribute Summary collapse

Attributes inherited from ExternalImage

#image_path

Instance Method Summary collapse

Methods inherited from ExternalImage

parse, #path

Methods inherited from ExternalResource

#find_value

Constructor Details

#initialize(uri, document) ⇒ ExternalFavicon

Returns a new instance of ExternalFavicon.



5
6
7
8
9
10
# File 'lib/link_preview/external_favicon.rb', line 5

def initialize(uri, document)
  @uri      = uri
  @document = document

  super(uri, favicon_path.to_s)
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



3
4
5
# File 'lib/link_preview/external_favicon.rb', line 3

def document
  @document
end

#favicon_elementObject (readonly)

Returns the value of attribute favicon_element.



3
4
5
# File 'lib/link_preview/external_favicon.rb', line 3

def favicon_element
  @favicon_element
end

#itemprop_elementObject (readonly)

Returns the value of attribute itemprop_element.



3
4
5
# File 'lib/link_preview/external_favicon.rb', line 3

def itemprop_element
  @itemprop_element
end

#open_graph_elementObject (readonly)

Returns the value of attribute open_graph_element.



3
4
5
# File 'lib/link_preview/external_favicon.rb', line 3

def open_graph_element
  @open_graph_element
end

#uriObject (readonly)

Returns the value of attribute uri.



3
4
5
# File 'lib/link_preview/external_favicon.rb', line 3

def uri
  @uri
end

Instance Method Details

#favicon_pathObject



12
13
14
# File 'lib/link_preview/external_favicon.rb', line 12

def favicon_path
  find_value(open_graph_element) || favicon_element['href'] || find_value(itemprop_element)
end