easy-box-packer 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/easy-box-packer.rb +4 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e39931d70dad5421a82dbe062c8826cf63e27db8
4
- data.tar.gz: f9a516ed16ec7c8d72beb901e648399462d42d40
3
+ metadata.gz: d62d68c7bf71b3125bac31ee0c01faa0b7d1adbb
4
+ data.tar.gz: 2c231b4132f149c6b3b5eabf222b2bfa222a254b
5
5
  SHA512:
6
- metadata.gz: 07a6251fdef61a2f4de967d3289e84f834dc4c4e33d1fa202cffce483d189ae56e99acea299cc0f6d1788e7998f3d8ee1de88f7f5f3226a5ad918bdba5d122b1
7
- data.tar.gz: d3df8428a5d8b7acd95fdbd87783a51020f1651aa31d85525d7286722ee09b817dc7e8db047623b655e514b82bb2d18b79b9252c6d401428c04a873beb7d421d
6
+ metadata.gz: 3fcd648f100ea6c72eac790cf9a9dfb9e1a4cd059c245f32313dfe262227ee86d9a1599fae1bfabb2f5db7b8308534af85bd695a984d61a4d418c0ee3e10b2d2
7
+ data.tar.gz: 174e2d04868c83e2b855c70e2b5ea10ad102dd8027290e297ffb13c1e027c877d4420e61e288bf3e6c95476732272481dee5fc46416ac3a001b98eb3d6037cb3
@@ -92,12 +92,13 @@ module EasyBoxPacker
92
92
  item_index: 1,
93
93
  min_vol: min_vol)
94
94
 
95
- possible_containers.map { |a| a.sort }.sort_by { |a| [a.inject(&:*), a.inject(&:+)] }.each do |c|
95
+ select_container = possible_containers.map { |a| a.sort }.sort_by { |a| [a.inject(&:*), a.inject(&:+)] }.each do |c|
96
96
  packing = pack(
97
97
  container: { dimensions: c },
98
98
  items: items)
99
- return c if packing[:packings].size == 1
99
+ break c if packing[:packings].size == 1
100
100
  end
101
+ check_container_is_bigger_than_greedy_box({dimensions: select_container}, items) ? item_greedy_box(items) : select_container
101
102
  end
102
103
 
103
104
  private
@@ -107,7 +108,7 @@ module EasyBoxPacker
107
108
  contents.map!(&:to_f)
108
109
  mean = contents.reduce(&:+)/n
109
110
  sum_sqr = contents.map {|x| x * x}.reduce(&:+)
110
- Math.sqrt((sum_sqr - n * mean * mean)/(n-1))
111
+ Math.sqrt(((sum_sqr - n * mean * mean)/(n-1)).abs)
111
112
  end
112
113
 
113
114
  def find_possible_container(possible_containers:,invalid_containers:,container:, items:, item_index:, min_vol:)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy-box-packer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aloha Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2017-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec