Sha256: d4029bd7f17082284e979d35db5ef611c54068c54fece66529ace4800a2bd664

Contents?: true

Size: 446 Bytes

Versions: 2

Compression:

Stored size: 446 Bytes

Contents

# custom runnable module
module Runnable
  def run
    reject!(&:done)
    each(&:display)
  end
end

# using forwardable to make a custom enumerable
class ShapeSystem
  include Enumerable, Runnable
  extend Forwardable
  def_delegators(:@polygons, :each, :reject!, :<<)

  attr_reader :bd

  def initialize(bd)
    @bd = bd
    @polygons = [] # Initialize the Array
  end

  def add_polygon(x, y)
    self << CustomShape.new(bd, x, y)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pbox2d-0.8.0-java examples/lib/shape_system.rb
pbox2d-0.6.0-java examples/lib/shape_system.rb