Class: Onebox::Engine::AmazonOnebox

Inherits:
Object
  • Object
show all
Includes:
Onebox::Engine, HTML, LayoutSupport
Defined in:
lib/onebox/engine/amazon_onebox.rb

Constant Summary

Constants included from Onebox::Engine

DEFAULT

Instance Attribute Summary

Attributes included from Onebox::Engine

#cache, #timeout, #uri

Instance Method Summary collapse

Methods included from LayoutSupport

#layout, max_text, #to_html

Methods included from Onebox::Engine

engines, included, #initialize, #options, #options=, #placeholder_html, #to_html

Instance Method Details

#http_paramsObject



26
27
28
# File 'lib/onebox/engine/amazon_onebox.rb', line 26

def http_params
  {'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3'}
end

#tldObject



22
23
24
# File 'lib/onebox/engine/amazon_onebox.rb', line 22

def tld
  @tld || @@matcher.match(@url)["tld"]
end

#urlObject



13
14
15
16
17
18
19
20
# File 'lib/onebox/engine/amazon_onebox.rb', line 13

def url
  if match && match[:id]
    _url = URI("http://www.amazon.#{tld}/gp/aw/d/" + URI::encode(match[:id]))
    _url.scheme = URI(@url).scheme
    return _url.to_s
  end
  @url
end