Class: Applitools::Base::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/applitools/base/point.rb

Constant Summary collapse

TOP_LEFT =
Point.new(0, 0)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Point

Returns a new instance of Point.



8
9
10
11
# File 'lib/applitools/base/point.rb', line 8

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

Instance Attribute Details

#xObject

Returns the value of attribute x.



3
4
5
# File 'lib/applitools/base/point.rb', line 3

def x
  @x
end

#yObject

Returns the value of attribute y.



3
4
5
# File 'lib/applitools/base/point.rb', line 3

def y
  @y
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



15
16
17
18
# File 'lib/applitools/base/point.rb', line 15

def ==(other)
  return super.==(other) unless other.is_a?(Point)
  @x == other.x && @y == other.y
end

#hashObject



22
23
24
# File 'lib/applitools/base/point.rb', line 22

def hash
  @x.hash & @y.hash
end

#to_hash(options = {}) ⇒ Object



26
27
28
# File 'lib/applitools/base/point.rb', line 26

def to_hash(options = {})
  options[:region] ? { left: left, top: top } : { x: x, y: y }
end

#valuesObject



30
31
32
# File 'lib/applitools/base/point.rb', line 30

def values
  [x, y]
end