Sha256: 3baa92f706292f4d782c51955df181c5c574d5c4fd74a31a1b4a44d11ae0fba8
Contents?: true
Size: 642 Bytes
Versions: 2
Compression:
Stored size: 642 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(row, col) end end pegs_class.new(collection_of_pegs: pegs) end def self.create_empty_peg(row, col, display_value = nil, peg_class = Peg) peg_class.new(display_value: display_value, row: row, col: col ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
games_bfox-0.3.0 | lib/games/mastermind/pegs_factory.rb |
games_bfox-0.2.0 | lib/games/mastermind/pegs_factory.rb |