Class: OnlyofficePdfParser::CursorPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_pdf_parser/helpers/cursor_point.rb

Overview

Class for working with cursor coordinates

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, top) ⇒ CursorPoint

Returns a new instance of CursorPoint.



8
9
10
11
# File 'lib/onlyoffice_pdf_parser/helpers/cursor_point.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_pdf_parser/helpers/cursor_point.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_pdf_parser/helpers/cursor_point.rb', line 6

def top
  @top
end

Instance Method Details

#==(other) ⇒ True, False

Compare object with other

Parameters:

  • other (Object)

    object to compare

Returns:

  • (True, False)

    result of comparison



32
33
34
35
36
37
38
# File 'lib/onlyoffice_pdf_parser/helpers/cursor_point.rb', line 32

def ==(other)
  if other.respond_to?(:left) && other.respond_to?(:top)
    @left == other.left && @top == other.top
  else
    false
  end
end

#[](name) ⇒ Object

Accessor of attributes like hash

Parameters:

  • name (Symbol)

    attribute name

Returns:

  • (Object)

    value of attribute



43
44
45
46
47
48
49
50
51
52
# File 'lib/onlyoffice_pdf_parser/helpers/cursor_point.rb', line 43

def [](name)
  case name
  when :width
    left
  when :height
    top
  else
    'Unknown attribute'
  end
end

#dupCursorPoint

Make a copy of object

Returns:



20
21
22
# File 'lib/onlyoffice_pdf_parser/helpers/cursor_point.rb', line 20

def dup
  CursorPoint.new(@left, @top)
end

#to_sString

Returns convert object to string.

Returns:

  • (String)

    convert object to string



25
26
27
# File 'lib/onlyoffice_pdf_parser/helpers/cursor_point.rb', line 25

def to_s
  "[#{@left}, #{@top}]"
end