Class: JLDrill::Tanaka::SearchResults
- Inherits:
-
Object
- Object
- JLDrill::Tanaka::SearchResults
- 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
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#sentences ⇒ Object
Returns the value of attribute sentences.
Instance Method Summary collapse
- #findWord(connection) ⇒ Object
- #getSentences ⇒ Object
- #getWordData ⇒ Object
-
#initialize(word, connections, sentences) ⇒ SearchResults
constructor
A new instance of SearchResults.
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
#connections ⇒ Object
Returns the value of attribute connections.
66 67 68 |
# File 'lib/jldrill/model/Tanaka.rb', line 66 def connections @connections end |
#sentences ⇒ Object
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 |
#getSentences ⇒ Object
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 |
#getWordData ⇒ Object
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 |