Class: ResellerRatingsSource

Inherits:
Source
  • Object
show all
Defined in:
lib/sources/reseller_ratings_source.rb

Constant Summary

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

Methods inherited from Source

affiliate_sources, #eql?, #fetch_offers, #hash, inherited, #keyname, keyname, keyname=, merchant_rating_sources, method_missing, #nullify_offer_url, offer_sources, #product_code_valid?, #product_page_link, source, sources, #to_s

Constructor Details

#initializeResellerRatingsSource

Returns a new instance of ResellerRatingsSource.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sources/reseller_ratings_source.rb', line 4

def initialize
  super(:name => 'ResellerRatings.com',
        :homepage => 'http://www.resellerratings.com/',
        :cpc => 0,
        :offer_enabled => false,
        :offer_ttl_seconds => 0,
        :use_for_merchant_ratings => true,
        :offer_affiliate => false,
        :supports_lifetime_ratings => true,
        :batch_fetch_delay => 5,
        :product_code_regexp => /^\d{9}$/,
        :product_code_examples => ['652196596', '676109333'],
        :product_page_link_erb => "http://resellerratings.nextag.com/<%= product_code %>/resellerratings/prices-html")
end

Instance Method Details

#code_from_merchant_source_page_url(merchant_source_page_url) ⇒ Object



27
28
29
# File 'lib/sources/reseller_ratings_source.rb', line 27

def code_from_merchant_source_page_url(merchant_source_page_url)
  nil
end

#fetch_merchant_source(merchant_source_page_url) ⇒ Object



31
32
33
34
# File 'lib/sources/reseller_ratings_source.rb', line 31

def fetch_merchant_source(merchant_source_page_url)
  delay_fetch
  ResellerRatingsAPI.fetch_merchant_source(merchant_source_page_url)
end

#format_rating(merchant_source) ⇒ Object



44
45
46
# File 'lib/sources/reseller_ratings_source.rb', line 44

def format_rating(merchant_source)
  '%01.1f/10' % (merchant_source.get_merchant_rating.to_f / 10.0)
end

#search_for_merchant_source(search_text) ⇒ Object



36
37
38
# File 'lib/sources/reseller_ratings_source.rb', line 36

def search_for_merchant_source(search_text)
  ResellerRatingsAPI.search_for_merchant_source(search_text)
end

#search_for_merchant_source_best_match(search_text) ⇒ Object



40
41
42
# File 'lib/sources/reseller_ratings_source.rb', line 40

def search_for_merchant_source_best_match(search_text)
  ResellerRatingsAPI.search_for_merchant_source_best_match(search_text)
end

#url_for_merchant_source_page(merchant_source_code) ⇒ Object



19
20
21
# File 'lib/sources/reseller_ratings_source.rb', line 19

def url_for_merchant_source_page(merchant_source_code)
  "http://www.resellerratings.com/seller#{merchant_source_code}.html"
end

#url_for_merchant_source_page_alt(merchant_source_alt_code) ⇒ Object



23
24
25
# File 'lib/sources/reseller_ratings_source.rb', line 23

def url_for_merchant_source_page_alt(merchant_source_alt_code)
  "http://www.resellerratings.com/store/#{merchant_source_alt_code}"
end