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(url, options = Onebox.options) ⇒ Preview
constructor
A new instance of Preview.
- #options ⇒ Object
- #placeholder_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url, options = Onebox.options) ⇒ Preview
Returns a new instance of Preview.
9 10 11 12 13 14 15 16 17 |
# File 'lib/onebox/preview.rb', line 9 def initialize(url, = Onebox.) @url = url @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
38 39 40 41 |
# File 'lib/onebox/preview.rb', line 38 def data return {} unless engine engine.data end |
#errors ⇒ Object
33 34 35 36 |
# File 'lib/onebox/preview.rb', line 33 def errors return {} unless engine engine.errors end |
#options ⇒ Object
43 44 45 |
# File 'lib/onebox/preview.rb', line 43 def OpenStruct.new(@options) end |
#placeholder_html ⇒ Object
26 27 28 29 30 31 |
# File 'lib/onebox/preview.rb', line 26 def placeholder_html return "" unless engine sanitize process_html engine.placeholder_html rescue *WEB_EXCEPTIONS "" end |
#to_s ⇒ Object
19 20 21 22 23 24 |
# File 'lib/onebox/preview.rb', line 19 def to_s return "" unless engine sanitize process_html engine_html rescue *WEB_EXCEPTIONS "" end |