Class: Kin::SKU

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = 0, inventory_status = '', sale_price = '', shipping_surcharge = '', attributes = {}) ⇒ SKU

Returns a new instance of SKU.



10
11
12
13
14
15
16
# File 'lib/sku.rb', line 10

def initialize(id=0,inventory_status='',sale_price='',shipping_surcharge='',attributes={})
  @id = id.to_i
  @inventory_status = inventory_status.to_s
  @sale_price = sale_price.to_s
  @shipping_surcharge = shipping_surcharge.to_s
  @attributes = attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#inventory_statusObject

Returns the value of attribute inventory_status.



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

def inventory_status
  @inventory_status
end

#msrp_priceObject

Returns the value of attribute msrp_price.



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

def msrp_price
  @msrp_price
end

#sale_priceObject

Returns the value of attribute sale_price.



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

def sale_price
  @sale_price
end

#shipping_surchargeObject

Returns the value of attribute shipping_surcharge.



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

def shipping_surcharge
  @shipping_surcharge
end

Instance Method Details

#initalize(obj = {}) ⇒ Object



5
6
7
8
# File 'lib/sku.rb', line 5

def initalize(obj={})
  raise "Invalid Argument" unless obj.is_a?(Hash)
  initialize(obj['id'], obj['inventory_status'], obj['sale_price'], obj['shipping_surcharge'], obj['attributes'])
end

#to_sObject



18
19
20
21
22
# File 'lib/sku.rb', line 18

def to_s
  vars = {}
  self.instance_variables.map {|v| vars[v.to_sym] = self.instance_variable_get(v)}
  vars
end