Class: Onebox::OpenGraph

Inherits:
Normalizer show all
Defined in:
lib/onebox/open_graph.rb

Direct Known Subclasses

Oembed

Instance Attribute Summary

Attributes inherited from Normalizer

#data

Instance Method Summary collapse

Methods inherited from Normalizer

#get, #method_missing

Constructor Details

#initialize(doc) ⇒ OpenGraph

Returns a new instance of OpenGraph.



5
6
7
# File 'lib/onebox/open_graph.rb', line 5

def initialize(doc)
  @data = extract(doc)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Onebox::Normalizer

Instance Method Details

#secure_image_urlObject



17
18
19
20
21
# File 'lib/onebox/open_graph.rb', line 17

def secure_image_url
  secure_url = URI(get(:image))
  secure_url.scheme = "https"
  secure_url.to_s
end

#titleObject



9
10
11
# File 'lib/onebox/open_graph.rb', line 9

def title
  get(:title, 80)
end

#title_attrObject



13
14
15
# File 'lib/onebox/open_graph.rb', line 13

def title_attr
  !title.nil? ? "title='#{title}'" : ""
end