Class: OnlyofficeWebdriverWrapper::Dimensions

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_webdriver_wrapper/dimensions.rb

Overview

Class for working with cursor coordinates

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, top) ⇒ Dimensions

Returns a new instance of Dimensions.



8
9
10
11
# File 'lib/onlyoffice_webdriver_wrapper/dimensions.rb', line 8

def initialize(left, top)
  @left = left
  @top = top
end

Instance Attribute Details

#leftObject Also known as: width, x

Returns the value of attribute left.



6
7
8
# File 'lib/onlyoffice_webdriver_wrapper/dimensions.rb', line 6

def left
  @left
end

#topObject Also known as: height, y

Returns the value of attribute top.



6
7
8
# File 'lib/onlyoffice_webdriver_wrapper/dimensions.rb', line 6

def top
  @top
end

Instance Method Details

#==(other) ⇒ Boolean

Compare two dimensions object

Parameters:

  • other (Object)

    object

Returns:

  • (Boolean)

    result of comparison



16
17
18
19
20
# File 'lib/onlyoffice_webdriver_wrapper/dimensions.rb', line 16

def ==(other)
  return false unless other.respond_to?(:left) && other.respond_to?(:top)

  @left == other.left && @top == other.top
end

#centerDimensions

Returns Center point of current dimension.

Returns:

  • (Dimensions)

    Center point of current dimension



33
34
35
# File 'lib/onlyoffice_webdriver_wrapper/dimensions.rb', line 33

def center
  Dimensions.new(@left / 2, @top / 2)
end

#to_sString

Returns String representation of Dimensions.

Returns:

  • (String)

    String representation of Dimensions



28
29
30
# File 'lib/onlyoffice_webdriver_wrapper/dimensions.rb', line 28

def to_s
  "Dimensions(left: #{@left}, top: #{@top})"
end