Class: Shoppr::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/shoppr/product.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cat_mash) ⇒ Product

Returns a new instance of Product.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/shoppr/product.rb', line 5

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

Instance Attribute Details

#feature_ratingObject

Returns the value of attribute feature_rating.



3
4
5
# File 'lib/shoppr/product.rb', line 3

def feature_rating
  @feature_rating
end

#overall_ratingObject

Returns the value of attribute overall_rating.



3
4
5
# File 'lib/shoppr/product.rb', line 3

def overall_rating
  @overall_rating
end

#ratingObject

Returns the value of attribute rating.



3
4
5
# File 'lib/shoppr/product.rb', line 3

def rating
  @rating
end

#rating_imageObject

Returns the value of attribute rating_image.



3
4
5
# File 'lib/shoppr/product.rb', line 3

def rating_image
  @rating_image
end

#review_countObject

Returns the value of attribute review_count.



3
4
5
# File 'lib/shoppr/product.rb', line 3

def review_count
  @review_count
end

#review_urlObject

Returns the value of attribute review_url.



3
4
5
# File 'lib/shoppr/product.rb', line 3

def review_url
  @review_url
end