binpack 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/binpack.rb +17 -4
  3. data/lib/binpack/version.rb +1 -1
  4. metadata +8 -10
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13b94b68af9606ace505845cc316c8832a31739b
4
+ data.tar.gz: 671e97364295cdfc99731d9939ad7ebbcf227869
5
+ SHA512:
6
+ metadata.gz: f6a13f94b5c25e2fb19143ea321ad0252f0967cdba9a56219e1c7678fc79f9e9d27e2cbb56dc6cc6e25af2cc7fa6ad93a1e3d686347ca7361d66143c6f5a7667
7
+ data.tar.gz: fb538cbe32e2fe1c1bb56c29bfa4f9bb86bea161e61e2ad6f63105aa71c0d627aa205b455214cdbb829731da8769adaf0600a9bc06630ff56ed1e68629731fb5
@@ -1,11 +1,20 @@
1
1
  #require "binpack/version"
2
2
 
3
3
  module Binpack
4
- class Item
5
- attr_reader :width, :height, :rotated, :obj
4
+ class UnrotatableItem
5
+ attr_reader :width, :height, :obj
6
+
7
+ def initialize(obj, width, height)
8
+ @obj, @width, @height = obj, width, height
9
+ end
10
+ end
11
+
12
+ class Item < UnrotatableItem
13
+ attr_reader :rotated
6
14
 
7
15
  def initialize(obj, width, height, rotated=false)
8
- @obj, @width, @height, @rotated = obj, width, height, rotated
16
+ super obj, width, height
17
+ @rotated = rotated
9
18
  end
10
19
 
11
20
  def rotate
@@ -23,7 +32,11 @@ module Binpack
23
32
  end
24
33
 
25
34
  def add(item)
26
- try_adding(item) or try_adding(item.rotate)
35
+ if added = try_adding(item)
36
+ return added
37
+ elsif item.is_a?(Item)
38
+ return try_adding(item.rotate)
39
+ end
27
40
  end
28
41
  alias_method "<<".to_sym, :add
29
42
 
@@ -1,3 +1,3 @@
1
1
  module Binpack
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kelley Reynolds
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-25 00:00:00.000000000 Z
11
+ date: 2014-10-13 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: 2 dimensional bin packing library adapted from a RubyQuiz solution by
15
14
  Ilmari Heikkinen
@@ -19,7 +18,7 @@ executables: []
19
18
  extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
22
- - .gitignore
21
+ - ".gitignore"
23
22
  - Gemfile
24
23
  - Rakefile
25
24
  - Readme.md
@@ -28,26 +27,25 @@ files:
28
27
  - lib/binpack/version.rb
29
28
  homepage: ''
30
29
  licenses: []
30
+ metadata: {}
31
31
  post_install_message:
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib
35
35
  required_ruby_version: !ruby/object:Gem::Requirement
36
- none: false
37
36
  requirements:
38
- - - ! '>='
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  required_rubygems_version: !ruby/object:Gem::Requirement
42
- none: false
43
41
  requirements:
44
- - - ! '>='
42
+ - - ">="
45
43
  - !ruby/object:Gem::Version
46
44
  version: '0'
47
45
  requirements: []
48
46
  rubyforge_project: binpack
49
- rubygems_version: 1.8.15
47
+ rubygems_version: 2.2.2
50
48
  signing_key:
51
- specification_version: 3
49
+ specification_version: 4
52
50
  summary: 2 dimensional bin packing library
53
51
  test_files: []