Class: Onebox::Preview
- Inherits:
-
Object
- Object
- Onebox::Preview
- Defined in:
- lib/onebox/preview.rb
Defined Under Namespace
Classes: InvalidURI
Instance Method Summary collapse
- #data ⇒ Object
- #errors ⇒ Object
-
#initialize(link, options = Onebox.options) ⇒ Preview
constructor
A new instance of Preview.
- #options ⇒ Object
- #placeholder_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(link, options = Onebox.options) ⇒ Preview
Returns a new instance of Preview.
10 11 12 13 14 15 16 17 18 |
# File 'lib/onebox/preview.rb', line 10 def initialize(link, = Onebox.) @url = link @options = .dup allowed_origins = @options[:allowed_iframe_origins] || Onebox::Engine.all_iframe_origins @options[:allowed_iframe_regexes] = Engine.origins_to_regexes(allowed_origins) @engine_class = Matcher.new(@url, @options).oneboxed end |
Instance Method Details
#data ⇒ Object
39 40 41 42 |
# File 'lib/onebox/preview.rb', line 39 def data return {} unless engine engine.data end |
#errors ⇒ Object
34 35 36 37 |
# File 'lib/onebox/preview.rb', line 34 def errors return {} unless engine engine.errors end |
#options ⇒ Object
44 45 46 |
# File 'lib/onebox/preview.rb', line 44 def OpenStruct.new(@options) end |
#placeholder_html ⇒ Object
27 28 29 30 31 32 |
# File 'lib/onebox/preview.rb', line 27 def placeholder_html return "" unless engine sanitize process_html engine.placeholder_html rescue *WEB_EXCEPTIONS "" end |
#to_s ⇒ Object
20 21 22 23 24 25 |
# File 'lib/onebox/preview.rb', line 20 def to_s return "" unless engine sanitize process_html engine_html rescue *WEB_EXCEPTIONS "" end |