Class: OnlyofficePdfParser::ArrayHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_pdf_parser/helpers/array_helper.rb

Overview

Methods to help working with array

Class Method Summary collapse

Class Method Details

.get_array_inclusion_indexes(array, included_array) ⇒ Array, Integer

Get list of indexes in which one array is included to another

Parameters:

  • array (Array)

    big array

  • included_array (Array)

    array to search

Returns:

  • (Array, Integer)

    indexes



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/onlyoffice_pdf_parser/helpers/array_helper.rb', line 10

def self.get_array_inclusion_indexes(array,
                                     included_array)
  index_array = []
  first_element = included_array.first
  array.each_with_index do |array_element, array_element_index|
    if array_element == first_element
      array_part = array.slice(array_element_index, included_array.length)
      index_array << array_element_index if array_part == included_array
    end
  end
  index_array
end