Class: Kin::SKU
- Inherits:
-
Object
- Object
- Kin::SKU
- Defined in:
- lib/sku.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#inventory_status ⇒ Object
Returns the value of attribute inventory_status.
-
#msrp_price ⇒ Object
Returns the value of attribute msrp_price.
-
#sale_price ⇒ Object
Returns the value of attribute sale_price.
-
#shipping_surcharge ⇒ Object
Returns the value of attribute shipping_surcharge.
Instance Method Summary collapse
- #initalize(obj = {}) ⇒ Object
-
#initialize(id = 0, inventory_status = '', sale_price = '', shipping_surcharge = '', attributes = {}) ⇒ SKU
constructor
A new instance of SKU.
- #to_s ⇒ Object
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
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/sku.rb', line 3 def attributes @attributes end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/sku.rb', line 3 def id @id end |
#inventory_status ⇒ Object
Returns the value of attribute inventory_status.
3 4 5 |
# File 'lib/sku.rb', line 3 def inventory_status @inventory_status end |
#msrp_price ⇒ Object
Returns the value of attribute msrp_price.
3 4 5 |
# File 'lib/sku.rb', line 3 def msrp_price @msrp_price end |
#sale_price ⇒ Object
Returns the value of attribute sale_price.
3 4 5 |
# File 'lib/sku.rb', line 3 def sale_price @sale_price end |
#shipping_surcharge ⇒ Object
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_s ⇒ Object
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 |