Class: JLDrill::Tanaka::SearchResults

Inherits:
Object
  • Object
show all
Defined in:
lib/jldrill/model/Tanaka.rb

Overview

Represents the results of searching the Tanaka reference library It is composed of a list of sentences.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word, connections, sentences) ⇒ SearchResults

Returns a new instance of SearchResults.



69
70
71
72
73
# File 'lib/jldrill/model/Tanaka.rb', line 69

def initialize(word, connections, sentences)
    @word = word
    @sentences = sentences
    @connections = connections
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



66
67
68
# File 'lib/jldrill/model/Tanaka.rb', line 66

def connections
  @connections
end

#sentencesObject

Returns the value of attribute sentences.



66
67
68
# File 'lib/jldrill/model/Tanaka.rb', line 66

def sentences
  @sentences
end

Instance Method Details

#findWord(connection) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/jldrill/model/Tanaka.rb', line 86

def findWord(connection)
    connection.split(" ").each do |word|
        if word.start_with?(@word)
            return word
        end
    end
    return ""
end

#getSentencesObject



75
76
77
78
79
80
81
82
83
84
# File 'lib/jldrill/model/Tanaka.rb', line 75

def getSentences
    retVal = []
    if !@connections.nil?
        wordData = getWordData
        @connections.each_with_index do |connection, i|
            retVal.push(Sentence.new(@sentences[connection], wordData[i]))
        end
    end
    return retVal
end

#getWordDataObject



95
96
97
98
99
100
101
# File 'lib/jldrill/model/Tanaka.rb', line 95

def getWordData
    wordData = []
    @connections.each_with_index do |connection, i|
        wordData.push(findWord(@sentences[connection + 1]))
    end
    return wordData 
end