bin_packing 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 729c8a0a3ebeb449568d02a4ec00f7a4ecc4a574
4
- data.tar.gz: 7c53d882f799e197c921245ac9135c2b3ccc7b9b
2
+ SHA256:
3
+ metadata.gz: 54d605afad8bf79dcfb7abb3cc589b54e2ea9ab298cb75d32570c13ecbbec7d6
4
+ data.tar.gz: d9262871c5bc9c33bf68d5c2caebc647c42fa99ea8c364b3f35bd8f6296fa636
5
5
  SHA512:
6
- metadata.gz: 5efb09d2832044bbd32fa250945eb7d7c0108df2c992a56c62ea85312b9dd3d76a262afc5c4570dc53dd5fe7fa47804da34aea47a1d8e69c8f33b4ba642e37c5
7
- data.tar.gz: 3d708805897abef9f009edb147d383f6b71654d9ed59d24abe20caab6632cbf6ac17c26dcc559e3218d2a297eba2dc40f5294e421b3ae754432f7f51281f7807
6
+ metadata.gz: b5f860651a0707f34f385235d899dfe2b1ff2132b0f69e7e81782257d4110ad95ad1b8df90ed81c741c4a80d4cf03173149205bbdadea1f124323b1c5fe7063f
7
+ data.tar.gz: cb3ad7491d7ca39d4f90060c28d747cf0ae0156e8a342b34e7f8bc1806a858f22282fecc0cce91bb6e452ea114897ca4da1eaac1e0b8681cfe4d8f9cfcaa7143
@@ -1,6 +1,6 @@
1
1
  module BinPacking
2
2
  class Box
3
- attr_accessor :width, :height, :x, :y, :packed
3
+ attr_accessor :width, :height, :x, :y, :packed, :can_rotate
4
4
 
5
5
  def initialize(width, height)
6
6
  @width = width
@@ -8,20 +8,21 @@ module BinPacking
8
8
  @x = 0
9
9
  @y = 0
10
10
  @packed = false
11
+ @can_rotate = true
11
12
  end
12
13
 
13
14
  def area
14
15
  @area ||= @width * @height
15
16
  end
16
17
 
17
- def rotate
18
- @width, @height = [@height, @width]
19
- end
20
-
21
18
  def packed?
22
19
  @packed
23
20
  end
24
21
 
22
+ def can_rotate?
23
+ @can_rotate
24
+ end
25
+
25
26
  def label
26
27
  "#{@width}x#{@height} at [#{@x},#{@y}]"
27
28
  end
@@ -8,7 +8,10 @@ module BinPacking
8
8
 
9
9
  free_rectangles.each do |free_rect|
10
10
  try_place_rect_in(free_rect, box, width, height, best_score)
11
- try_place_rect_in(free_rect, box, height, width, best_score)
11
+
12
+ if box.can_rotate?
13
+ try_place_rect_in(free_rect, box, height, width, best_score)
14
+ end
12
15
  end
13
16
 
14
17
  best_score
@@ -1,3 +1,3 @@
1
1
  module BinPacking
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bin_packing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MAK IT
@@ -30,8 +30,10 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.0.0
33
- description: |
34
- Provides algorithm for placing rectangles (box-es) in one or multiple rectangular areas (bins) with reasonable allocation efficiency.
33
+ description: 'Provides algorithm for placing rectangles (box-es) in one or multiple
34
+ rectangular areas (bins) with reasonable allocation efficiency.
35
+
36
+ '
35
37
  email: info@makit.lv
36
38
  executables: []
37
39
  extensions: []
@@ -75,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
77
  version: '0'
76
78
  requirements: []
77
79
  rubyforge_project:
78
- rubygems_version: 2.2.2
80
+ rubygems_version: 2.7.6
79
81
  signing_key:
80
82
  specification_version: 4
81
83
  summary: 2D bin packing algorithm