Class: Onebox::Preview

Inherits:
Object
  • Object
show all
Defined in:
lib/onebox/preview.rb

Defined Under Namespace

Classes: InvalidURI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(link, parameters = Onebox.options) ⇒ Preview

Returns a new instance of Preview.


7
8
9
10
11
12
# File 'lib/onebox/preview.rb', line 7

def initialize(link, parameters = Onebox.options)
  @url = link
  @options = parameters
  @cache = options.cache
  @engine_class = Matcher.new(@url).oneboxed
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache


3
4
5
# File 'lib/onebox/preview.rb', line 3

def cache
  @cache
end

Instance Method Details

#optionsObject


28
29
30
# File 'lib/onebox/preview.rb', line 28

def options
  OpenStruct.new(@options)
end

#placeholder_htmlObject


21
22
23
24
25
26
# File 'lib/onebox/preview.rb', line 21

def placeholder_html
  return "" unless engine
  sanitize process_html engine.placeholder_html
rescue *WEB_EXCEPTIONS
  ""
end

#to_sObject


14
15
16
17
18
19
# File 'lib/onebox/preview.rb', line 14

def to_s
  return "" unless engine
  sanitize process_html engine_html
rescue *WEB_EXCEPTIONS
  ""
end