lib/tafel.rb in tafel-1.0.0 vs lib/tafel.rb in tafel-1.0.1

- old
+ new

@@ -23,11 +23,11 @@ #++ module Tafel - VERSION = '1.0.0' + VERSION = '1.0.1' def self.table?(o) o.is_a?(Array) && o.all? { |r| r.is_a?(Array) } end @@ -102,10 +102,12 @@ a = Array.new(h) { Array.new(w) } iterate(ss) do |x, y, s| + next unless s + left = x > 0 ? ss[y][x - 1] : nil above = y > 0 ? ss[y - 1][x] : nil woff = left ? left[2] + left[0] : 0 hoff = above ? above[3] + above[1] : 0 @@ -120,11 +122,15 @@ protected # well... def self.size(o) - table?(o) ? [ o.collect { |r| r.size }.max, o.size ] : [ 0, 0 ] + if table?(o) && o.any? + [ o.collect { |r| r.size }.max, o.size ] + else + [ 0, 0 ] + end end def self.copy(target, woff, hoff, source) if table?(source) @@ -138,10 +144,10 @@ table.first.size.times do |x| table.size.times do |y| yield(x, y, table[y][x]) end - end + end if table.any? end def self.narrow_class(x) return Array if x.is_a?(Array)