Class: Range

Inherits:
Object show all
Defined in:
lib/accessibility/bridge/macruby.rb,
lib/accessibility/bridge/mri.rb

Overview

accessibility-core extensions to the Range class

Instance Method Summary collapse

Instance Method Details

#relative_to(max) ⇒ Range

Returns a new Range instance which has negative values in the receiver expanded relative to max

Examples:


(1..10).relative_to(10)   # => (1..10)
(-3..-1).relative_to(10)  # => (7..9)

Parameters:

  • max (Fixnum)

Returns:



211
212
213
214
215
216
# File 'lib/accessibility/bridge/mri.rb', line 211

def relative_to max
  beg = adjust_index self.begin, max
  len = adjust_index self.end, max
  len -= 1 if exclude_end?
  beg..len
end

#to_axAXValueRef

Returns:

  • (AXValueRef)

Raises:

  • (ArgumentError)


84
85
86
87
88
89
90
91
92
# File 'lib/accessibility/bridge/macruby.rb', line 84

def to_ax
  raise ArgumentError, "can't convert negative index" if last < 0 || first < 0
  length = if exclude_end?
             last - first
           else
             last - first + 1
           end
  CFRange.new(first, length).to_ax
end