Sha256: 62922b0dd3c722771c109900808ae9e1184c97063d6c0d7eb09b9ae083dc1765

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

module ZPNG
  class Pixels
    include Enumerable

    module ImageEnum
      def each
        @image.height.times do |y|
          @image.width.times do |x|
            yield @image[x,y]
          end
        end
      end
    end

    module ScanLineEnum
      def each
        @scanline.width.times do |x|
          yield @scanline[x]
        end
      end
    end

    def initialize x
      case x
      when Image
        @image = x
        extend ImageEnum
      when ScanLine
        @scanline = x
        extend ScanLineEnum
      else raise ArgumentError, "don't know how to enumerate #{x.inspect}"
      end
    end

    def == other
      self.to_a == other.to_a
    end

    def uniq
      self.to_a.uniq
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zpng-0.2.2 lib/zpng/pixels.rb