Sha256: 5b1674d5fe67761e4b04ea389c169ab20d416205670a75c48fb9d62ab276eaf2

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 Bytes

Contents

module NasaRovers
  class Coord
    def self.origin
      @origin ||= new(0, 0)
    end

    def self.factory(data)
      new(*data.split(" "))
    end

    attr_accessor :x, :y

    def initialize(x, y)
      @x, @y = x.to_i, y.to_i
    end

    def to_s
      "#{x} #{y}"
    end

    def >=(other)
      x >= other.x && y >= other.y
    end

    def <=(other)
      x <= other.x && y <= other.y
    end

    def ==(other)
      x == other.x && y == other.y
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nasa_rovers-1.0.1 lib/nasa_rovers/coord.rb