Class: Corraios::Packer
- Inherits:
-
Object
- Object
- Corraios::Packer
- Defined in:
- lib/corraios/packer.rb
Instance Attribute Summary collapse
-
#containers ⇒ Object
readonly
Returns the value of attribute containers.
Instance Method Summary collapse
- #add_item(attributes) ⇒ Object
- #amount_of_posts ⇒ Object
-
#initialize ⇒ Packer
constructor
A new instance of Packer.
- #total_weight ⇒ Object
Constructor Details
#initialize ⇒ Packer
Returns a new instance of Packer.
7 8 9 |
# File 'lib/corraios/packer.rb', line 7 def initialize() @containers = [] end |
Instance Attribute Details
#containers ⇒ Object (readonly)
Returns the value of attribute containers.
5 6 7 |
# File 'lib/corraios/packer.rb', line 5 def containers @containers end |
Instance Method Details
#add_item(attributes) ⇒ Object
11 12 13 14 |
# File 'lib/corraios/packer.rb', line 11 def add_item(attributes) container = build_container(attributes) add_to_containers container end |
#amount_of_posts ⇒ Object
20 21 22 |
# File 'lib/corraios/packer.rb', line 20 def amount_of_posts @containers.size end |
#total_weight ⇒ Object
16 17 18 |
# File 'lib/corraios/packer.rb', line 16 def total_weight @containers.inject(0) { |sum, item| sum + item.weight }.round(3) end |