class MusicTodayApiWrapper::Resources::Product
Attributes
category[RW]
description[RW]
image[RW]
name[RW]
price[RW]
uid[RW]
variants[RW]
Public Class Methods
from_hash(hash)
click to toggle source
rubocop:disable AbcSize
# 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
new(uid, name, description, category, price, image = MusicTodayApiWrapper::Resources::Image.new, variants = [])
click to toggle source
rubocop:disable ParameterLists
# 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