class LLT::Review::Common::Report
Attributes
sentences[R]
Public Class Methods
new(id, sentences)
click to toggle source
Calls superclass method
LLT::Review::Helpers::Reportable::new
# File lib/llt/review/common/report.rb, line 10 def initialize(id, sentences) super(id) @sentences = sentences end
Public Instance Methods
collect_multithreaded()
click to toggle source
# File lib/llt/review/common/report.rb, line 33 def collect_multithreaded slice_size = @sentences.size / 4 slice_size = 1 if slice_size.zero? threads = [] @sentences.each_slice(slice_size) do |slice| temp_container = Report.new(nil, {}) threads << Thread.new do slice.map { |_, s| s.report }.each do |rep| rep.each { |_, r| temp_container.add(r) } end temp_container end end temps = threads.flat_map { |t| t.join; t.value } temps.each { |temp| temp.each { |_, r| add(r) }} end
collect_singlethreaded()
click to toggle source
# File lib/llt/review/common/report.rb, line 27 def collect_singlethreaded @sentences.map { |_, s| s.report }.each do |rep| rep.each { |_, r| add(r) } end end
report()
click to toggle source
# File lib/llt/review/common/report.rb, line 15 def report @report ||= begin add_report_container if RUBY_ENGINE == 'jruby' collect_multithreaded else collect_singlethreaded end @container.each { |_, rep| rep.sort! } end end
xml_attributes()
click to toggle source
# File lib/llt/review/common/report.rb, line 50 def xml_attributes { id: @id } end
Private Instance Methods
add_report_container()
click to toggle source
# File lib/llt/review/common/report.rb, line 56 def add_report_container add(namespace.const_get(:Generic).new(:sentences, @sentences.count)) end
namespace()
click to toggle source
# File lib/llt/review/common/report.rb, line 60 def namespace # needs to be overriden by subclasses self.class end