Sha256: 3a91802894e60772d7550fad5556f4225e83885cac7025ffe071f9dc4a0871d5

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

module Examples
  FizzBuzz = Orchestra::Operation.new 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

2 entries across 2 versions & 1 rubygems

Version Path
ntl-orchestra-0.9.2 test/examples/fizz_buzz.rb
ntl-orchestra-0.9.1 test/examples/fizz_buzz.rb