Class: NSArray

Inherits:
Object
  • Object
show all
Includes:
Accessibility::NSArrayCompat
Defined in:
lib/ax_elements/nsarray_compat.rb

Overview

AXElements extensions for NSArray

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Accessibility::NSArrayCompat

#method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Accessibility::NSArrayCompat

Class Method Details

.arrayArray

Create and return a new empty array

Returns:

  • (Array)


137
138
139
# File 'lib/ax_elements/nsarray_compat.rb', line 137

def self.array
  []
end

.arrayWithArray(ary) ⇒ Object

Create a new array with the same contents as the given array

Parameters:

  • ary (Array)


129
130
131
# File 'lib/ax_elements/nsarray_compat.rb', line 129

def self.arrayWithArray ary
  ary.dup
end

Instance Method Details

#fifthObject

Equal to self[4]



111
112
113
# File 'lib/ax_elements/nsarray_compat.rb', line 111

def fifth
  self[4]
end

#forty_twoObject Also known as: the_reddit

Equal to self[41]

Also known as accessing "the reddit".



119
120
121
# File 'lib/ax_elements/nsarray_compat.rb', line 119

def forty_two
  self[41]
end

#fourthObject

Equal to self[3]



105
106
107
# File 'lib/ax_elements/nsarray_compat.rb', line 105

def fourth
  self[3]
end

#from(position) ⇒ Array

Returns the tail of the array from position

Examples:


[1, 2, 3, 4].from(0)   # => [1, 2, 3, 4]
[1, 2, 3, 4].from(2)   # => [3, 4]
[1, 2, 3, 4].from(10)  # => []
[].from(0)             # => []

Parameters:

  • position (Fixnum)

Returns:

  • (Array)


73
74
75
# File 'lib/ax_elements/nsarray_compat.rb', line 73

def from position
  self[position, length] || []
end

#secondObject

Equal to self[1]



93
94
95
# File 'lib/ax_elements/nsarray_compat.rb', line 93

def second
  self[1]
end

#thirdObject

Equal to self[2]



99
100
101
# File 'lib/ax_elements/nsarray_compat.rb', line 99

def third
  self[2]
end

#to(count) ⇒ Array

Returns the beginning of the array up to position

[1, 2, 3, 4].to(0) # => [1] [1, 2, 3, 4].to(2) # => [1, 2, 3] [1, 2, 3, 4].to(10) # => [1, 2, 3, 4] [].to(0) # => []

Parameters:

  • count (Fixnum)

Returns:

  • (Array)


87
88
89
# File 'lib/ax_elements/nsarray_compat.rb', line 87

def to count
  take count + 1
end