class Terrestrial::Cli::Bootstrapper::Result
Public Class Methods
new()
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 26 def initialize @result_index = 0 end
Public Instance Methods
[](i)
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 65 def [](i) entries[i] end
add(entry_hash)
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 46 def add(entry_hash) match = entries.detect {|e| e.string == entry_hash["string"] } if match match.add_occurence(entry_hash, next_result_index) else entries << Entry.from_hash(entry_hash, next_result_index) end end
all_occurences()
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 42 def all_occurences entries.flat_map(&:as_separate_occurences) end
each(&block)
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 30 def each(&block) entries.each do |entry| block.call(entry) end end
each_occurence(&block)
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 36 def each_occurence(&block) entries.flat_map(&:as_separate_occurences).each do |entry| block.call(entry) end end
entries()
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 69 def entries @entries ||= [] end
exclude_occurences(indexes)
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 55 def exclude_occurences(indexes) entries.each do |entry| entry.occurences.delete_if {|occurence| indexes.include? occurence.result_index } end end
length()
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 61 def length entries.length end
Private Instance Methods
next_result_index()
click to toggle source
# File lib/terrestrial/cli/bootstrapper.rb, line 75 def next_result_index @result_index += 1 @result_index - 1 end