Sha256: f8451b509d9a9e3e0f49ea7515ce2001f1b80cf2cb50d6809b5d69c5778d4089

Contents?: true

Size: 348 Bytes

Versions: 396

Compression:

Stored size: 348 Bytes

Contents

module BookKeeping
  VERSION = 1
end

class Phrase
  def initialize(source)
    @source = source
  end

  def word_count
    data = Hash.new(0)
    each_word do |word|
      data[word] += 1
    end
    data
  end

  private

  attr_reader :source

  def each_word
    source.downcase.scan(/\b[\w']+\b/) do |word|
      yield word
    end
  end
end

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.138 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.137 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.136 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.135 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.134 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.133 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.132 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.131 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.130 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.129 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.128 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.127 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.126 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.125 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.124 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.123 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.122 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.121 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb
trackler-2.2.1.120 tracks/ruby/exercises/word-count/.meta/solutions/word_count.rb