Sha256: 945ff5b8948349d77e9bb60c89522c0141dd7aa1e3bac9b4fe9549c7d33089cd

Contents?: true

Size: 1.09 KB

Versions: 21

Compression:

Stored size: 1.09 KB

Contents

require "#{File.dirname(__FILE__)}/../lib/stages"

include Stages

#count the occurance of each letter in these song lyrics
@lyrics = 
  { :do => 'doe a deer a female deer',
    :re => 'ray a drop of golden sun',
    :mi => 'me a name I call myself',
    :fa => 'far a long long way to run',
    :so => 'a needle pulling thread',
    :la => 'a note to follow so',
    :ti => 'a drink with jam and bread'}

def setup_pipeline
  get_lyric = Map.new{ |x| @lyrics[x]}
  
  
  each_character = Each.new{ |x| x.chars }
  trim_whitespace = Select.new{ |x| x != ' '}
  letters_in_each_line = Wrap.new(get_lyric | each_character | trim_whitespace)
  each_note = Each.new @lyrics.keys
  count_everything = Count.new
  each_letter = Each.new
  
  
  each_note | letters_in_each_line | each_letter | count_everything
end

puts setup_pipeline.run.inspect

puts "one line at a time"
lyrics = Each.new(@lyrics.keys)
letters_in_chunks = Wrap.new(Map.new{ |x| @lyrics[x]} | Each.new{ |x| x.chars})
each_letter = Each.new{ |x| x.values.first }
count = Count.new

p2 = lyrics | letters_in_chunks | each_letter | count

puts p2.run.inspect

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
stages-1.2.1 examples/sing_subpipes.rb
stages-1.2.0 examples/sing_subpipes.rb
stages-1.1.5 examples/sing_subpipes.rb
stages-1.1.2 examples/sing_subpipes.rb
stages-1.1.1 examples/sing_subpipes.rb
stages-1.0.1 examples/sing_subpipes.rb
stages-1.0.0 examples/sing_subpipes.rb
stages-0.4.1 examples/sing_subpipes.rb
stages-0.4.0 examples/sing_subpipes.rb
stages-0.3.4 examples/sing_subpipes.rb
stages-0.3.3 examples/sing_subpipes.rb
stages-0.3.2 examples/sing_subpipes.rb
stages-0.3.1 examples/sing_subpipes.rb
stages-0.3.0 examples/sing_subpipes.rb
stages-0.2.10 examples/sing_subpipes.rb
stages-0.2.9 examples/sing_subpipes.rb
stages-0.2.8 examples/sing_subpipes.rb
stages-0.2.7 examples/sing_subpipes.rb
stages-0.2.6 examples/sing_subpipes.rb
stages-0.2.5 examples/sing_subpipes.rb