Sha256: bf35a173396587d79ac00dcbe2c33d59af3bc2144fbf54b1f60f0a3319052387

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

module Shoppr
  class Product    
    attr_accessor :review_count, :rating, :rating_image, :review_url, :overall_rating, :feature_rating, :rating_image
    
    def initialize(cat_mash)   
      Shoppr.map_mash_attrs(self, cat_mash)
      
      @offers = self.offers && self.offers.offer ? self.offers.offer.map {|offer| Offer.new(offer) } : []
      
      @overall_rating = self.reviews.averageRating.overallRating rescue nil
      
      @reviews = self.reviews.consumerReview ? [self.reviews.consumerReview].flatten.map {|rev| ConsumerReview.new(rev)} : [] rescue []
      
      @review_count = self.rating.reviewCount
      @review_url = self.rating.reviewURL
      
      @rating_image = Image.new(self.rating.ratingImage) rescue nil
      
      @rating = self.rating.rating     
      
      @images = self.images.image.map {|image| Image.new(image) } rescue []
      
      @specifications = self.specifications.featureGroup.map {|spec| FeatureGroup.new(spec)} rescue []
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppr-0.2.3 lib/shoppr/product.rb