Class: BestBuy::Product

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

Overview

:reek:TooManyInstanceVariables

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(init_params) ⇒ Product

rubocop:disable Metrics/AbcSize



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/best_buy/models/product.rb', line 13

def initialize(init_params)
  @active = init_params[:active]
  @alternate_categories = init_params[:alternate_categories]
  @category_path = init_params[:category_path]
  @images = init_params[:images]&.map do |image_params|
    Image.new(image_params)
  end
  @name = init_params[:name]
  @offers = init_params[:offers]&.map do |offer_params|
    Offer.new(offer_params)
  end
  @regular_price = init_params[:regular_price]
  @sale_price = init_params[:sale_price]
  @shipping_cost = init_params[:shipping_cost]
  @shipping_levels_of_service = init_params[:shipping_levels_of_service]&.map do |slos_params|
    ShippingLevelOfService.new(slos_params)
  end
  @sku = init_params[:sku]
  @type = init_params[:type]
  @upc = init_params[:upc]
  @url = init_params[:url]

  @raw_attributes = init_params
end

Instance Attribute Details

#activeObject (readonly)

Returns the value of attribute active.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def active
  @active
end

#alternate_categoriesObject (readonly)

Returns the value of attribute alternate_categories.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def alternate_categories
  @alternate_categories
end

#category_pathObject (readonly)

Returns the value of attribute category_path.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def category_path
  @category_path
end

#imagesObject (readonly)

Returns the value of attribute images.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def name
  @name
end

#offersObject (readonly)

Returns the value of attribute offers.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def offers
  @offers
end

#raw_attributesObject (readonly)

Returns the value of attribute raw_attributes.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def raw_attributes
  @raw_attributes
end

#regular_priceObject (readonly)

Returns the value of attribute regular_price.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def regular_price
  @regular_price
end

#sale_priceObject (readonly)

Returns the value of attribute sale_price.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def sale_price
  @sale_price
end

#shipping_costObject (readonly)

Returns the value of attribute shipping_cost.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def shipping_cost
  @shipping_cost
end

#shipping_levels_of_serviceObject (readonly)

Returns the value of attribute shipping_levels_of_service.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def shipping_levels_of_service
  @shipping_levels_of_service
end

#skuObject (readonly)

Returns the value of attribute sku.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def sku
  @sku
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def type
  @type
end

#upcObject (readonly)

Returns the value of attribute upc.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def upc
  @upc
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/best_buy/models/product.rb', line 8

def url
  @url
end