Sha256: 8fa54ae9419555ce7801804b1c813bf5d169bada14c3afb2f9a70b9aaa4daacc

Contents?: true

Size: 454 Bytes

Versions: 1

Compression:

Stored size: 454 Bytes

Contents

require "nasa_rovers/coord"

module NasaRovers
  class Plateau
    def self.factory(data, coord_class=Coord)
      new(*data.split(" "), coord_class)
    end

    attr_reader :bot_lt, :top_rt

    def initialize(x, y, coord_class=Coord)
      @bot_lt = coord_class.origin
      @top_rt = coord_class.new(x, y)
    end

    def include?(coord)
      coord >= bot_lt && coord <= top_rt
    end

    def to_s
      "#{bot_lt} - #{top_rt}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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