Class: BuySource
Constant Summary collapse
- BUY_MERCHANT_PERMALINK =
'buy-com'
- BUY_AFFILIATE_PID =
'3332520'
- BUY_AFFILIATE_URL_PREFIX =
"http://affiliate.buy.com/gateway.aspx?adid=17662&pid=#{BUY_AFFILIATE_PID}&aid=10391416&sURL="
Constants inherited from Source
Source::SIMPLE_SOURCES_YAML_FILE
Instance Attribute Summary
Attributes inherited from Source
#batch_fetch_delay, #cpc, #for_product_info, #for_review_aggregates, #homepage, #mappable, #name, #offer_affiliate, #offer_enabled, #offer_ttl_seconds, #product_code_examples, #product_code_regexp, #product_page_link_erb, #search_token_separator, #search_url, #supports_lifetime_ratings, #use_for_merchant_ratings
Instance Method Summary collapse
- #affiliate_wrap_deal_url(deal_url, nullify = false) ⇒ Object
-
#initialize ⇒ BuySource
constructor
A new instance of BuySource.
- #nullify_offer_url(offer_url) ⇒ Object
- #offer_affiliate_for_merchant?(merchant) ⇒ Boolean
Methods inherited from Source
affiliate_sources, #code_from_merchant_source_page_url, #eql?, #fetch_merchant_source, #fetch_offers, #format_rating, #hash, inherited, #keyname, keyname, keyname=, merchant_rating_sources, method_missing, offer_sources, #product_code_valid?, #product_page_link, source, sources, #to_s, #url_for_merchant_source_page, #url_for_merchant_source_page_alt
Constructor Details
#initialize ⇒ BuySource
Returns a new instance of BuySource.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sources/buy_source.rb', line 6 def initialize super(:name => 'Buy.com', :homepage => 'http://www.buy.com/', :cpc => 7, :offer_enabled => false, :offer_ttl_seconds => 86400, :use_for_merchant_ratings => false, :offer_affiliate => true, :supports_lifetime_ratings => false, :batch_fetch_delay => 2, :product_code_regexp => /^\d{9}$/, :product_code_examples => ['208464207', '211986388'], :product_page_link_erb => "http://www.buy.com/retail/product.asp?sku=<%= product_code %>") end |
Instance Method Details
#affiliate_wrap_deal_url(deal_url, nullify = false) ⇒ Object
29 30 31 32 33 |
# File 'lib/sources/buy_source.rb', line 29 def affiliate_wrap_deal_url(deal_url, nullify=false) offer_url = BUY_AFFILIATE_URL_PREFIX offer_url += CGI::escape(deal_url) nullify ? nullify_offer_url(offer_url) : offer_url end |
#nullify_offer_url(offer_url) ⇒ Object
21 22 23 |
# File 'lib/sources/buy_source.rb', line 21 def nullify_offer_url(offer_url) offer_url.gsub(/#{BUY_AFFILIATE_PID}/, '') end |
#offer_affiliate_for_merchant?(merchant) ⇒ Boolean
25 26 27 |
# File 'lib/sources/buy_source.rb', line 25 def offer_affiliate_for_merchant?(merchant) !merchant.nil? && merchant.permalink == BUY_MERCHANT_PERMALINK end |