Class: ATSPI::Accessible::Text::Offset
- Inherits:
-
Object
- Object
- ATSPI::Accessible::Text::Offset
- Defined in:
- lib/atspi/accessible/text/offset.rb
Overview
Represents an offset in a ATSPI::Accessible::Text.
Direct Known Subclasses
Attributes collapse
-
#character ⇒ Character
Its character.
-
#hyperlink ⇒ Hyperlink?
(also: #link)
Its hyperlink.
-
#text_around(boundary) ⇒ Range
The text between the closest boundary to the left and right.
Representations collapse
-
#inspect ⇒ String
Itself as an inspectable string.
-
#to_i ⇒ Integer
Its integer representation.
Instance Method Details
#character ⇒ Character
Returns its character.
25 26 27 |
# File 'lib/atspi/accessible/text/offset.rb', line 25 def character Character.new(@text_native, to_i) end |
#hyperlink ⇒ Hyperlink? Also known as: link
Returns its hyperlink. Will be nil if its text does not implement the hypertext interface or there simply is no hyperlink at the offset.
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 |
#inspect ⇒ String
Returns 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.
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_i ⇒ Integer
Returns its integer representation.
47 48 49 |
# File 'lib/atspi/accessible/text/offset.rb', line 47 def to_i @offset end |