Sha256: f5f2e9a35063be4516e462bda1a7b2b22624a015a54e5b4e5ce661271363a78b
Contents?: true
Size: 598 Bytes
Versions: 2
Compression:
Stored size: 598 Bytes
Contents
module JustCheckers # = Direction # # The Direction that something is moving on a 2d plane class Direction # New objects can be instantiated with # # * +x+ - x magnitude # * +y+ - y magnitude # # ==== Example: # # Instantiates a new Direction # JustCheckers::Direction.new({ # x: 1, # y: 1 # }) def initialize(x, y) @x, @y = x, y end attr_reader :x, :y # check if directions are equal by seeing if their magnitudes are equal. def ==(other) self.x == other.x && self.y == other.y end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
just_checkers-0.1.1 | lib/just_checkers/direction.rb |
just_checkers-0.1.0 | lib/just_checkers/direction.rb |