Class: MusicTodayApiWrapper::Resources::Product
- Inherits:
-
Object
- Object
- MusicTodayApiWrapper::Resources::Product
- Defined in:
- lib/resources/product.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#description ⇒ Object
Returns the value of attribute description.
-
#image ⇒ Object
Returns the value of attribute image.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#variants ⇒ Object
Returns the value of attribute variants.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
rubocop:disable AbcSize.
Instance Method Summary collapse
-
#initialize(uid, name, description, category, price, image = MusicTodayApiWrapper::Resources::Image.new, variants = []) ⇒ Product
constructor
rubocop:disable ParameterLists.
Constructor Details
#initialize(uid, name, description, category, price, image = MusicTodayApiWrapper::Resources::Image.new, variants = []) ⇒ Product
rubocop:disable ParameterLists
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/resources/product.rb', line 16 def initialize(uid, name, description, category, price, image = MusicTodayApiWrapper::Resources::Image.new, variants = []) @uid = uid @name = name @description = description @category = category @price = price @image = image @variants = variants end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
7 8 9 |
# File 'lib/resources/product.rb', line 7 def category @category end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/resources/product.rb', line 7 def description @description end |
#image ⇒ Object
Returns the value of attribute image.
7 8 9 |
# File 'lib/resources/product.rb', line 7 def image @image end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/resources/product.rb', line 7 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
7 8 9 |
# File 'lib/resources/product.rb', line 7 def price @price end |
#uid ⇒ Object
Returns the value of attribute uid.
7 8 9 |
# File 'lib/resources/product.rb', line 7 def uid @uid end |
#variants ⇒ Object
Returns the value of attribute variants.
7 8 9 |
# File 'lib/resources/product.rb', line 7 def variants @variants end |
Class Method Details
.from_hash(hash) ⇒ Object
rubocop:disable AbcSize
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/resources/product.rb', line 28 def self.from_hash(hash) image = Image.new(hash['imageUrlSmall'], hash['imageUrlMedium'], hash['imageUrlLarge']) product = Product.new(hash['id'], hash['name'], hash['lang']['en']['textDesc'], hash['categoryName'], hash['listPrice'], image) hash['variants'].each do |variant| product.variants << Variant.from_hash(variant) end product end |