Sha256: 779bf9088c654df81a92c05457c3fd28db7112c656a279ad00f80bbaa8f0fb66

Contents?: true

Size: 416 Bytes

Versions: 2

Compression:

Stored size: 416 Bytes

Contents

module TFG
  module Support
    class Sequence
      def initialize(first, generator=nil, &block)
        self.first = first
        self.generator = generator || block
      end

      def next
        if previous
          self.previous = generator.call(previous)
        else
          self.previous = first
        end
      end

      private

      attr_accessor :first, :previous, :generator
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tfg_support-1.1.1 lib/tfg/support/sequence.rb
tfg_support-1.0.1 lib/tfg/support/sequence.rb