Class: Array
- Includes
 - Enumerable
 - Defined in
 - lib/kyanite/set.rb,
lib/kyanite/array.rb,
lib/kyanite/dictionary.rb,
lib/kyanite/string/chars.rb,
lib/kyanite/enumerable/structure.rb,
lib/kyanite/enumerable/enumerable_strings.rb,
lib/kyanite/enumerable/enumerable_numerics.rb,
lib/kyanite/enumerable/enumerable_enumerables.rb 
- Subclasses
 - ArrayOfEnumerables, ArrayOfNumerics, ArrayOfStrings
 
Array Additions
- Kyanite definitions
 - Kyanite tests and examples
 - Usage
 - 
require ‘kyanite/array’
 
Required from Facets Array:
- delete_unless(&block)
 - 
Inverse of delete_if
 - delete_values(*values)
 - 
Delete multiple values from array (findet und löscht bestimmte Werte)
 - delete_values_at(*selectors)
 - 
Delete multiple values from array given indexes or index range (löscht Elemente an bestimmten Positionen)
 - rotate(n=1)
 - 
Rotates an array’s elements from back to front n times (alles rückt n Positionen auf)
 - select!{ |obj| block }
 - 
As with select but modifies the Array in place.
 - to_h(arrayed=nil)
 - 
Converts a two-element associative array into a hash.
 
Cast (collapse)
- 
  
    
      - (ArrayOfEnumerables) to_array_of_enumerables 
    
    
  
  
    
Returns ArrayOfEnumerables (this is an Array with modul EnumerableEnumerables included).
 - 
  
    
      - (ArrayOfNumerics) to_array_of_numerics 
    
    
  
  
    
Returns ArrayOfNumerics (this is an Array with modul EnumerableNumerics included).
 - 
  
    
      - (ArrayOfStrings) to_array_of_strings 
    
    
  
  
    
Returns ArrayOfStrings (this is an Array with modul EnumerableStrings included).
 - 
  
    
      - (Dictionary) to_dictionary 
    
    
  
  
    
Returns Dictionary.
 - 
  
    
      - (OrderedSet) to_ordered_set 
    
    
  
  
    
Returns OrderedSet, tests and examples here.
 - - (SortedSet) to_sorted_set
 
Upcase and Downcase with support for special letters like german umlauts (collapse)
- 
  
    
      - (String) to_s_utf8 
    
    
  
  
    
reverse of String#to_array_of_codepoints.
 
Structure Reflection (collapse)
- 
  
    
      - (Object) contentclass(options = {}) 
    
    
  
  
    included from Enumerable
What kind of objects contains the collection? Returns the class of content elements, or Object if there are several.
 - 
  
    
      - (Array) distribution(mode = :size) 
    
    
  
  
    included from Enumerable
Returns the distribution of size, class or any other characteristics of the enumerated elements.
 - - (true) is_collection? included from Enumerable
 
Instance Method Summary (collapse)
- 
  
    
      - (Integer) rephrase_index(i, style = :inv) 
    
    
  
  
    
Rephrases the index of an Array pos / neg / inv.
 - 
  
    
      - (Object) shift_complement 
    
    
  
  
    
Cuts the front portion, and returns the rest.
 - 
  
    
      - (Object) transpose! 
    
    
  
  
    included from Enumerable
In-place-variant of transpose.
 
Instance Method Details
- (Object) contentclass(options = {}) Originally defined in module Enumerable
What kind of objects contains the collection? Returns the class of content elements, or Object if there are several.
Parameters is the accuracy with which the content is checked.
- :precision => 1
 - 
only the first element is checked
 - :precision => 2
 - 
the first and the last elements are checked (STANDARD)
 - :precision => :all
 - 
every element is checked
 - :ignore_nil => true
 - 
NilClass will not be listed (STANDARD)
 - :ignore_nil => false
 - 
NilClass will be listed
 
Tests and examples here.
- (Array) distribution(mode = :size) Originally defined in module Enumerable
Returns the distribution of size, class or any other characteristics of the enumerated elements. See also Hash#distribution. Tests and examples here.
- (true) is_collection? Originally defined in module Enumerable
- (Integer) rephrase_index(i, style = :inv)
Rephrases the index of an Array pos / neg / inv.
- :pos
 - 
The index is rephrased as a positive integer
 - :detect_last
 - 
The index is rephrased as a positive integer, but the last index is -1
 - :neg
 - 
The index is rephrased as a negative integer
 - :inv
 - 
if it was positive, then it will get negative, and vice versa
 
See tests and examples here
      69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102  | 
    
      # File 'lib/kyanite/array.rb', line 69 def rephrase_index(i, style=:inv) return i if i > (size-1) return i if i < -size case style when :inv if i >=0 # pos >> neg (i - size) else # neg >> pos (i + size) end when :pos if i >= 0 # pos bleibt i else # neg >> pos (i + size) end when :neg if i >= 0 # pos >> neg (i - size) else # neg bleibt i end when :detect_last if i >= 0 # pos bleibt eigentlich if (i == size-1) -1 # nur der Letzte wird -1 genannt else i end else # neg >> pos (i + size) end end #case end  | 
  
- (Object) shift_complement
Cuts the front portion, and returns the rest. If the remainder is only one element, it' not returned as an array but as single element. Useful for recursions. Example:
[1,2,3].shift_complement  =>  [2,3]
[1,2,3].shift_complement.shift_complement  =>  3
[1,2,3].shift_complement.shift_complement.shift_complement  =>  nil
See tests and examples here.
      47 48 49 50 51 52 53  | 
    
      # File 'lib/kyanite/array.rb', line 47 def shift_complement if self.size > 2 self[1..-1] else self[-1] end end  | 
  
- (ArrayOfEnumerables) to_array_of_enumerables
Returns ArrayOfEnumerables (this is an Array with modul EnumerableEnumerables included)
      61 62 63  | 
    
      # File 'lib/kyanite/enumerable/enumerable_enumerables.rb', line 61 def to_array_of_enumerables ArrayOfEnumerables.new(self) end  | 
  
- (ArrayOfNumerics) to_array_of_numerics
Returns ArrayOfNumerics (this is an Array with modul EnumerableNumerics included)
      137 138 139  | 
    
      # File 'lib/kyanite/enumerable/enumerable_numerics.rb', line 137 def to_array_of_numerics ArrayOfNumerics.new(self) end  | 
  
- (ArrayOfStrings) to_array_of_strings
Returns ArrayOfStrings (this is an Array with modul EnumerableStrings included)
      50 51 52  | 
    
      # File 'lib/kyanite/enumerable/enumerable_strings.rb', line 50 def to_array_of_strings ArrayOfStrings.new(self) end  | 
  
- (Dictionary) to_dictionary
Returns Dictionary
      77 78 79 80 81 82 83 84  | 
    
      # File 'lib/kyanite/dictionary.rb', line 77 def to_dictionary # TODO: effizienter result = Dictionary.new self.each do | zeile | result << zeile end result end  | 
  
- (OrderedSet) to_ordered_set
Returns OrderedSet, tests and examples here.
      184 185 186  | 
    
      # File 'lib/kyanite/set.rb', line 184 def to_ordered_set OrderedSet.new(self) end  | 
  
- (String) to_s_utf8
reverse of String#to_array_of_codepoints
      267 268 269  | 
    
      # File 'lib/kyanite/string/chars.rb', line 267 def to_s_utf8 self.pack("U*").encode('utf-8') end  | 
  
- (SortedSet) to_sorted_set
      191 192 193  | 
    
      # File 'lib/kyanite/set.rb', line 191 def to_sorted_set SortedSet.new(self) end  | 
  
- (Object) transpose! Originally defined in module Enumerable
In-place-variant of transpose.