Sha256: 42f7bbdbb2bf9685d0fd9c126414781e4987a66fccfab4f8d9178aa45d1e6e04
Contents?: true
Size: 659 Bytes
Versions: 151
Compression:
Stored size: 659 Bytes
Contents
class Snake module Model class Vertebra ORIENTATIONS = %i[north east south west] # orientation is needed for snake occuppied cells (but not apple cells) attr_reader :snake attr_accessor :row, :column, :orientation def initialize(snake: , row: , column: , orientation: ) @row = row || rand(snake.game.height) @column = column || rand(snake.game.width) @orientation = orientation || ORIENTATIONS.sample @snake = snake end # inspect is overridden to prevent printing very long stack traces def inspect "#{super[0, 150]}... >" end end end end
Version data entries
151 entries across 151 versions & 2 rubygems