Sha256: 39f26083f4153a1c394e0a1846ab68a50e0e75e74c0e5c97460dab78c2fb4cf9
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
module Examples FizzBuzz = Orchestra::Operation.new do step :make_array do depends_on :up_to provides :array execute do up_to.times.to_a end end step :apply_fizzbuzz do iterates_over :array provides :fizzbuzz execute do |num| next if num == 0 # filter 0 from the output str = '' str << "Fizz" if num % 3 == 0 str << "Buzz" if num % 5 == 0 str << num.to_s if str.empty? str end end finally do depends_on :stdout iterates_over :fizzbuzz execute do |str| stdout.puts str end end end InteractiveFizzBuzz = Orchestra::Operation.new do step :prompt_user do depends_on :stdin, :stdout provides :up_to execute do stdout.puts "How high would you like to go?" stdout.print " => " stdout.flush value = stdin.gets value.to_i end end finally Examples::FizzBuzz end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ntl-orchestra-0.9.5 | test/examples/fizz_buzz.rb |