Sha256: 284fbade696b3feefbe22e8140c62317ca8b99b492247c5b60f7ea43cbe742ff

Contents?: true

Size: 505 Bytes

Versions: 1

Compression:

Stored size: 505 Bytes

Contents

require_relative 'pegs'
require_relative 'peg'

module MM
  module PegsFactory
    def self.build_empty_pegs(rows = 12, cols = 4, pegs_class = Pegs)
      pegs = Array.new(rows) do
        Array.new(cols)
      end

      pegs.each_with_index do |element, row|
        element.each_index do |col|
          pegs[row][col] = create_empty_peg
        end
      end

      pegs_class.new(collection_of_pegs: pegs)
    end

    def self.create_empty_peg( peg_class = Peg)
      peg_class.new
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
games_bfox-0.4.0 lib/games/mastermind/pegs_factory.rb