Sha256: 6f0241dca63f88677a79210beeda7ba4e233690dec9f3f08016e25e110c99a35

Contents?: true

Size: 310 Bytes

Versions: 2

Compression:

Stored size: 310 Bytes

Contents

module TfgSupport
  class Sequence

    def initialize(args, &block)
      @current_value, @generator = args, block
    end

    # return the next element in the sequence

    def next
      @current_value = @generator.call(@current_value) if @called
      @called = true
      @current_value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tfg_support-0.2.1 lib/tfg_support/sequence.rb
tfg_support-0.1.1 lib/tfg_support/sequence.rb