class Textoken::Findings

This class duty is to collect splitted words with array index no And also handles making uniq of multiple words in the same index due to Regexps that reveal same/closer results

Public Class Methods

new() click to toggle source
# File lib/textoken/findings.rb, line 6
def initialize
  @collection = []
end

Public Instance Methods

collection() click to toggle source

collection will return a sorted and unique array of tokens

# File lib/textoken/findings.rb, line 18
def collection
  @collection.uniq { |w| "#{w[0]}#{w[1]}" }.sort_by(&:first)
end
push(index, word) click to toggle source

Here we will push items to collection array with index number index number will help us to sort and make array unique

# File lib/textoken/findings.rb, line 12
def push(index, word)
  type_check(index, word)
  @collection << [index, word]
end
result() click to toggle source

result will return a one dimensional array of words

# File lib/textoken/findings.rb, line 23
def result
  collection.map(&:last)
end

Private Instance Methods

type_check(i, word) click to toggle source
# File lib/textoken/findings.rb, line 29
def type_check(i, word)
  return if word.is_a?(String) && (i.is_a?(IntClass) || i.is_a?(Float))
  Textoken.type_err("#{word} and #{i} has to be a String and Integer")
end