Class: ATSPI::Accessible::Text::Offset

Inherits:
Object
  • Object
show all
Defined in:
lib/atspi/accessible/text/offset.rb

Overview

Represents an offset in a ATSPI::Accessible::Text.

Direct Known Subclasses

Caret

Attributes collapse

Representations collapse

Instance Method Details

#characterCharacter

Returns its character.

Returns:



25
26
27
# File 'lib/atspi/accessible/text/offset.rb', line 25

def character
  Character.new(@text_native, to_i)
end

Returns its hyperlink. Will be nil if its text does not implement the hypertext interface or there simply is no hyperlink at the offset.

Returns:

  • (Hyperlink, nil)

    its hyperlink. Will be nil if its text does not implement the hypertext interface or there simply is no hyperlink at the offset.

See Also:



36
37
38
39
40
41
# File 'lib/atspi/accessible/text/offset.rb', line 36

def hyperlink
  if @text_native.hypertext_iface
    idx = @text_native.link_index(to_i)
    Hyperlink.new(@text_native, @text_native.link(idx)) if idx != -1
  end
end

#inspectString

Returns itself as an inspectable string.

Returns:

  • (String)

    itself as an inspectable string



52
53
54
55
# File 'lib/atspi/accessible/text/offset.rb', line 52

def inspect
  "#<#{self.class.name}:0x#{'%x14' % __id__} @to_i=#{to_i} " <<
    "@character=#{character.to_s.inspect} @text_around=#{text_around(:word).to_s.inspect}>"
end

#text_around(boundary) ⇒ Range

Returns the text between the closest boundary to the left and right.

Parameters:

  • boundary (Symbol)

    the boundary type derived from libatspi’s AtspiTextGranularity enum by removing the prefix ATSPI_TEXT_GRANULARITY_ and making it lowercase

Returns:

  • (Range)

    the text between the closest boundary to the left and right

See Also:



20
21
22
# File 'lib/atspi/accessible/text/offset.rb', line 20

def text_around(boundary)
  Range.new(@text_native, @text_native.string_at_offset(to_i, boundary))
end

#to_iInteger

Returns its integer representation.

Returns:

  • (Integer)

    its integer representation



47
48
49
# File 'lib/atspi/accessible/text/offset.rb', line 47

def to_i
  @offset
end