Sha256: a313f8d13296281a9092d9c7fff2cfd15ea68ef3adbee7ea1db5595b1920915d

Contents?: true

Size: 541 Bytes

Versions: 1

Compression:

Stored size: 541 Bytes

Contents

require 'bitmapped/commands/base_command'

module Bitmapped
  module Commands
    module CommandsHelper
      def valid_cooridinates(bitmap, x, y)
        if (0 <= x && x <= bitmap.columns) && (0 <= y && y <= bitmap.rows)
          true
        else
          false
        end
      end

      def coordinates_to_array_indexes(bitmap, x, y)
        x = x.to_i - 1
        y = y.to_i - 1
        if valid_cooridinates(bitmap, x, y)
          [x, y]
        else
          raise InvalidCoordinatesError
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitmapped-0.2.0 lib/bitmapped/commands/commands_helper.rb