Class: Textoken::Findings
- Inherits:
-
Object
- Object
- Textoken::Findings
- Defined in:
- lib/textoken/findings.rb
Overview
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
Instance Method Summary collapse
-
#collection ⇒ Object
collection will return a sorted and unique array of tokens.
-
#initialize ⇒ Findings
constructor
A new instance of Findings.
-
#push(index, word) ⇒ Object
Here we will push items to collection array with index number index number will help us to sort and make array unique.
-
#result ⇒ Object
result will return a one dimensional array of words.
Constructor Details
#initialize ⇒ Findings
Returns a new instance of Findings.
6 7 8 |
# File 'lib/textoken/findings.rb', line 6 def initialize @collection = [] end |
Instance Method Details
#collection ⇒ Object
collection will return a sorted and unique array of tokens
18 19 20 |
# File 'lib/textoken/findings.rb', line 18 def collection @collection.uniq { |w| "#{w[0]}#{w[1]}" }.sort_by(&:first) end |
#push(index, word) ⇒ Object
Here we will push items to collection array with index number index number will help us to sort and make array unique
12 13 14 15 |
# File 'lib/textoken/findings.rb', line 12 def push(index, word) type_check(index, word) @collection << [index, word] end |
#result ⇒ Object
result will return a one dimensional array of words
23 24 25 |
# File 'lib/textoken/findings.rb', line 23 def result collection.map(&:last) end |