Class: ProductSet

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ ProductSet

Returns a new instance of ProductSet.



3
4
5
6
7
8
9
10
# File 'lib/product_set.rb', line 3

def initialize(attributes) 
  @item_name = attributes[:item_name] 
  @item_description = attributes[:item_description] 
  @item_category = attributes[:item_category] 
  @item_id = attributes[:item_id] 
  @item_image = attributes[:item_image] 
  @aisle_number = attributes[:aisle_number] 
end

Instance Attribute Details

#aisle_numberObject (readonly)

Returns the value of attribute aisle_number.



2
3
4
# File 'lib/product_set.rb', line 2

def aisle_number
  @aisle_number
end

#item_categoryObject (readonly)

Returns the value of attribute item_category.



2
3
4
# File 'lib/product_set.rb', line 2

def item_category
  @item_category
end

#item_descriptionObject (readonly)

Returns the value of attribute item_description.



2
3
4
# File 'lib/product_set.rb', line 2

def item_description
  @item_description
end

#item_idObject (readonly)

Returns the value of attribute item_id.



2
3
4
# File 'lib/product_set.rb', line 2

def item_id
  @item_id
end

#item_imageObject (readonly)

Returns the value of attribute item_image.



2
3
4
# File 'lib/product_set.rb', line 2

def item_image
  @item_image
end

#item_nameObject (readonly)

Returns the value of attribute item_name.



2
3
4
# File 'lib/product_set.rb', line 2

def item_name
  @item_name
end

Class Method Details

.from_xml(xml) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/product_set.rb', line 12

def self.from_xml(xml) 
  new( :item_name => xml.css("Itemname").text, 
       :item_description => xml.css("ItemDescription").text,
       :item_category => xml.css("ItemCategory").text,
       :item_id => xml.css("ItemID").text,
       :item_image => xml.css("ItemImage").text,
       :aisle_number => xml.css("AisleNumber").text) 
end