Module: TipsanityMerchantExtractor::Amazon
- Included in:
- FindAmazon
- Defined in:
- lib/tipsanity_merchant_extractor/amazon.rb
Defined Under Namespace
Modules: FindAmazon
Class Method Summary collapse
Instance Method Summary collapse
- #filtered_asin_from_amazon_path(merchant_url) ⇒ Object
- #is_merchant_amazon?(merchant_url) ⇒ Boolean
- #merchant_amazon_path(merchant_url) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
5 6 7 8 9 |
# File 'lib/tipsanity_merchant_extractor/amazon.rb', line 5 def self.extended(base) if base == AttributeExtractor base.send :include, FindAmazon end end |
Instance Method Details
#filtered_asin_from_amazon_path(merchant_url) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tipsanity_merchant_extractor/amazon.rb', line 27 def filtered_asin_from_amazon_path(merchant_url) split_path = self.merchant_amazon_path(merchant_url).split('/') if split_path.include? 'gp' if block_given? @is_dp = false yield @is_dp else asin = split_path[split_path.index('gp')+2] end elsif split_path.include? 'dp' if block_given? @is_dp = true yield @is_dp else asin = split_path[split_path.index('dp')+1] end else "path does not have asin" end end |
#is_merchant_amazon?(merchant_url) ⇒ Boolean
11 12 13 14 15 16 17 |
# File 'lib/tipsanity_merchant_extractor/amazon.rb', line 11 def is_merchant_amazon?(merchant_url) if URI(merchant_url).host == TipsanityMerchantExtractor::RegisteredMerchantList::REGISTERED_MERCHANT[:amazon] block_given? ? true : TipsanityMerchantExtractor::RegisteredMerchantList::REGISTERED_MERCHANT[:amazon] else false end end |
#merchant_amazon_path(merchant_url) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/tipsanity_merchant_extractor/amazon.rb', line 19 def merchant_amazon_path(merchant_url) if self.is_merchant_amazon?(merchant_url){} path = URI(merchant_url).path else "It is not amazon merchant" end end |