Sha256: 80132526339dfaafdf2069133410cba278d0d6dab0e803f924fbd22bc4ccb646

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

module Examples
  FizzBuzz = Orchestra.define do
    node :make_array do
      depends_on :up_to
      provides :array
      perform do
        up_to.times.to_a
      end
    end

    node :apply_fizzbuzz do
      iterates_over :array
      provides :fizzbuzz
      perform 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 :print do
      depends_on :io
      iterates_over :fizzbuzz
      perform do |str|
        io.puts str
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ntl-orchestra-0.9.0 test/examples/fizz_buzz.rb