Class: RubyPsigate::Item
- Inherits:
-
Object
- Object
- RubyPsigate::Item
- Includes:
- HashVariables, NumberValidationMethods
- Defined in:
- lib/ruby_psigate/item.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
(also: #itemdescription)
Returns the value of attribute desc.
-
#price ⇒ Object
(also: #itemprice)
Returns the value of attribute price.
-
#qty ⇒ Object
(also: #itemqty)
Returns the value of attribute qty.
-
#unique_id ⇒ Object
(also: #itemid)
Returns the value of attribute unique_id.
Instance Method Summary collapse
- #<<(item_option) ⇒ Object
-
#initialize(parameters = {}) ⇒ Item
constructor
End hashable.
- #options ⇒ Object
- #to_hash ⇒ Object
Methods included from HashVariables
Methods included from NumberValidationMethods
Constructor Details
#initialize(parameters = {}) ⇒ Item
End hashable
35 36 37 |
# File 'lib/ruby_psigate/item.rb', line 35 def initialize(parameters = {}) @options = [] end |
Instance Attribute Details
#desc ⇒ Object Also known as: itemdescription
Returns the value of attribute desc.
12 13 14 |
# File 'lib/ruby_psigate/item.rb', line 12 def desc @desc end |
#price ⇒ Object Also known as: itemprice
Returns the value of attribute price.
11 12 13 |
# File 'lib/ruby_psigate/item.rb', line 11 def price @price end |
#qty ⇒ Object Also known as: itemqty
Returns the value of attribute qty.
11 12 13 |
# File 'lib/ruby_psigate/item.rb', line 11 def qty @qty end |
#unique_id ⇒ Object Also known as: itemid
Returns the value of attribute unique_id.
12 13 14 |
# File 'lib/ruby_psigate/item.rb', line 12 def unique_id @unique_id end |
Instance Method Details
#<<(item_option) ⇒ Object
49 50 51 52 53 |
# File 'lib/ruby_psigate/item.rb', line 49 def << (item_option) raise InvalidItemOption unless item_option.is_a?(RubyPsigate::ItemOption) @options << item_option return self end |
#options ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/ruby_psigate/item.rb', line 55 def holder = [] @options.each do |opt| holder << opt.instance_variable_get(:@option) end holder end |
#to_hash ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_psigate/item.rb', line 20 def to_hash @return_hash = super unless .count == 0 @return_hash[:Option] = {} .each do |opt| opt = opt.first key = opt[0].to_sym value = opt[1] @return_hash[:Option][key] = value end end @return_hash end |