Module: Api::PointExtension

Defined in:
lib/sc2ai/protocol/extensions/point.rb

Overview

Adds additional functionality to message object Api::Point

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/sc2ai/protocol/extensions/point.rb', line 11

def eql?(other)
  self.class == other.class && hash == other.hash
end

#hashObject



5
6
7
8
9
# File 'lib/sc2ai/protocol/extensions/point.rb', line 5

def hash
  # Only one plane is ever used. Ignore hashing on z
  # [x, y, z].hash
  [x, y].hash
end

#to_p2dApi::Point2D

Creates a Point2D using x and y

Returns:



17
18
19
# File 'lib/sc2ai/protocol/extensions/point.rb', line 17

def to_p2d
  Api::Point2D.new(x: x, y: y)
end