Class: Moo::Model::Pack
Constant Summary collapse
- PRODUCT_CODES =
['businesscard', 'minicard', 'postcard', 'holidaycard', 'sticker'].freeze
Instance Attribute Summary collapse
-
#cards ⇒ Object
Returns the value of attribute cards.
-
#image_basket ⇒ Object
Returns the value of attribute image_basket.
-
#num_cards ⇒ Object
Returns the value of attribute num_cards.
-
#product_code ⇒ Object
Returns the value of attribute product_code.
-
#product_version ⇒ Object
Returns the value of attribute product_version.
-
#sides ⇒ Object
Returns the value of attribute sides.
Instance Method Summary collapse
- #fill_side_nums ⇒ Object
-
#initialize {|_self| ... } ⇒ Pack
constructor
A new instance of Pack.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Pack
Returns a new instance of Pack.
8 9 10 11 12 13 |
# File 'lib/moo/model/pack.rb', line 8 def initialize @cards = [] @sides = [] @product_version = 0 yield self if block_given? end |
Instance Attribute Details
#cards ⇒ Object
Returns the value of attribute cards.
4 5 6 |
# File 'lib/moo/model/pack.rb', line 4 def cards @cards end |
#image_basket ⇒ Object
Returns the value of attribute image_basket.
4 5 6 |
# File 'lib/moo/model/pack.rb', line 4 def image_basket @image_basket end |
#num_cards ⇒ Object
Returns the value of attribute num_cards.
4 5 6 |
# File 'lib/moo/model/pack.rb', line 4 def num_cards @num_cards end |
#product_code ⇒ Object
Returns the value of attribute product_code.
4 5 6 |
# File 'lib/moo/model/pack.rb', line 4 def product_code @product_code end |
#product_version ⇒ Object
Returns the value of attribute product_version.
4 5 6 |
# File 'lib/moo/model/pack.rb', line 4 def product_version @product_version end |
#sides ⇒ Object
Returns the value of attribute sides.
4 5 6 |
# File 'lib/moo/model/pack.rb', line 4 def sides @sides end |
Instance Method Details
#fill_side_nums ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/moo/model/pack.rb', line 41 def fill_side_nums counter = 1 @sides.reject {|s| s.side_num.is_a? Numeric}.each do |s| s.side_num = counter counter += 1 end end |
#to_hash ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/moo/model/pack.rb', line 28 def to_hash hash = { numCards: num_cards, productCode: product_code, productVersion: product_version, sides: sides.map {|s| s.to_hash } } hash[:imageBasket] = image_basket.to_hash unless image_basket.nil? hash end |
#to_json ⇒ Object
24 25 26 |
# File 'lib/moo/model/pack.rb', line 24 def to_json to_hash.to_json end |