Sha256: 5313f676fa0fad2ae02c6d57af1269016263612ee28516d724d032b79030f18b

Contents?: true

Size: 313 Bytes

Versions: 20

Compression:

Stored size: 313 Bytes

Contents

# A parallel WordCount. Depends on the 'wc' utility. 
class WordCount < CloudCrowd::Action
  
  # Count the words in a single book.
  def process
    (`wc -w #{input_path}`).match(/\A\s*(\d+)/)[1].to_i
  end
  
  # Sum the total word count.
  def merge
    input.inject(0) {|sum, count| sum + count }
  end
  
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
documentcloud-cloud-crowd-0.0.6 actions/word_count.rb
documentcloud-cloud-crowd-0.1.0 actions/word_count.rb
documentcloud-cloud-crowd-0.1.1 actions/word_count.rb
documentcloud-cloud-crowd-0.2.0 actions/word_count.rb
documentcloud-cloud-crowd-0.2.1 actions/word_count.rb
documentcloud-cloud-crowd-0.2.2 actions/word_count.rb
documentcloud-cloud-crowd-0.2.3 actions/word_count.rb
cloud-crowd-0.3.1 actions/word_count.rb
cloud-crowd-0.3.0 actions/word_count.rb
cloud-crowd-0.2.9 actions/word_count.rb
cloud-crowd-0.2.8 actions/word_count.rb
cloud-crowd-0.2.7 actions/word_count.rb
cloud-crowd-0.2.6 actions/word_count.rb
cloud-crowd-0.2.5 actions/word_count.rb
cloud-crowd-0.2.4 actions/word_count.rb
cloud-crowd-0.2.3 actions/word_count.rb
cloud-crowd-0.2.2 actions/word_count.rb
cloud-crowd-0.2.1 actions/word_count.rb
cloud-crowd-0.2.0 actions/word_count.rb
cloud-crowd-0.1.0 actions/word_count.rb