Sha256: 90cc792e9accd84d9c65c5cc4d1ab8fcd848fd08e583e94cd00786574d3833cd

Contents?: true

Size: 363 Bytes

Versions: 10

Compression:

Stored size: 363 Bytes

Contents

module JustGo
  Vector = Struct.new(:origin, :destination) do
    def magnitude
      if dx.abs == 0
        dy.abs
      elsif dy.abs == 0
        dx.abs
      else
        nil 
      end
    end

    def orthogonal?
      dx == 0 || dy == 0
    end

    def dx
      destination.x - origin.x
    end

    def dy
      destination.y - origin.y
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
just_go-0.1.10 lib/just_go/vector.rb
just_go-0.1.9 lib/just_go/vector.rb
just_go-0.1.8 lib/just_go/vector.rb
just_go-0.1.7 lib/just_go/vector.rb
just_go-0.1.6 lib/just_go/vector.rb
just_go-0.1.5 lib/just_go/vector.rb
just_go-0.1.4 lib/just_go/vector.rb
just_go-0.1.3 lib/just_go/vector.rb
just_go-0.1.2 lib/just_go/vector.rb
just_go-0.1.0 lib/just_go/vector.rb