Class: LinkThumbnailer::Scrapers::Opengraph::Image::Base
- Inherits:
-
Base
- Object
- SimpleDelegator
- Base
- Base
- LinkThumbnailer::Scrapers::Opengraph::Image::Base
show all
- Defined in:
- lib/link_thumbnailer/scrapers/opengraph/image.rb
Overview
Handles ‘og:image` attributes.
Direct Known Subclasses
Url
Instance Attribute Summary
Attributes inherited from Base
#attribute_name, #config, #document, #website
Instance Method Summary
collapse
Methods inherited from Base
#applicable?
Methods inherited from Base
#applicable?, #call, #initialize
Instance Method Details
#attribute ⇒ Object
43
44
45
|
# File 'lib/link_thumbnailer/scrapers/opengraph/image.rb', line 43
def attribute
'og:image'
end
|
#model ⇒ Object
23
24
25
26
27
28
|
# File 'lib/link_thumbnailer/scrapers/opengraph/image.rb', line 23
def model
nodes.map do |n|
uri = LinkThumbnailer::URI.new(n.attributes['content'])
modelize(n, uri.to_s) if uri.valid?
end.compact
end
|
#modelize(node, text = nil) ⇒ Object
30
31
32
|
# File 'lib/link_thumbnailer/scrapers/opengraph/image.rb', line 30
def modelize(node, text = nil)
model_class.new(text, size)
end
|
#nodes ⇒ Object
38
39
40
41
|
# File 'lib/link_thumbnailer/scrapers/opengraph/image.rb', line 38
def nodes
nodes = meta_xpaths(attribute: attribute)
nodes.empty? ? meta_xpaths(attribute: attribute, key: :name) : nodes
end
|
#size ⇒ Object
47
48
49
|
# File 'lib/link_thumbnailer/scrapers/opengraph/image.rb', line 47
def size
[width.to_i, height.to_i] if width && height
end
|
#value ⇒ Object
19
20
21
|
# File 'lib/link_thumbnailer/scrapers/opengraph/image.rb', line 19
def value
model
end
|