Class: Onebox::Preview
- Inherits:
-
Object
- Object
- Onebox::Preview
- Defined in:
- lib/onebox/preview.rb
Defined Under Namespace
Classes: InvalidURI
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(link, parameters = Onebox.options) ⇒ Preview
constructor
A new instance of Preview.
- #options ⇒ Object
- #placeholder_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(link, parameters = Onebox.options) ⇒ Preview
Returns a new instance of Preview.
8 9 10 11 12 13 |
# File 'lib/onebox/preview.rb', line 8 def initialize(link, parameters = Onebox.) @url = link = parameters @cache = .cache @engine_class = Matcher.new(@url).oneboxed end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
6 7 8 |
# File 'lib/onebox/preview.rb', line 6 def cache @cache end |
Class Method Details
.web_exceptions ⇒ Object
33 34 35 |
# File 'lib/onebox/preview.rb', line 33 def self.web_exceptions [Net::HTTPServerException, OpenURI::HTTPError, Timeout::Error, Net::HTTPError, Errno::ECONNREFUSED] end |
Instance Method Details
#options ⇒ Object
29 30 31 |
# File 'lib/onebox/preview.rb', line 29 def OpenStruct.new() end |
#placeholder_html ⇒ Object
22 23 24 25 26 27 |
# File 'lib/onebox/preview.rb', line 22 def placeholder_html return "" unless engine sanitize process_html engine.placeholder_html rescue *Onebox::Preview.web_exceptions "" end |
#to_s ⇒ Object
15 16 17 18 19 20 |
# File 'lib/onebox/preview.rb', line 15 def to_s return "" unless engine sanitize process_html engine_html rescue *Onebox::Preview.web_exceptions "" end |