Sha256: 6b16e3049bbea840d40b0fb3473fecf9c2287fc80ff4e6a2e5da2a81ab78c254
Contents?: true
Size: 873 Bytes
Versions: 1
Compression:
Stored size: 873 Bytes
Contents
# frozen_string_literal: true module Pull class Values DEFAULT_ABORT_PROC = -> () { puts "abort abort" } def initialize(array, on_abort = DEFAULT_ABORT_PROC) array = objectify(array) unless array.kind_of?(Array) @array = array @index = 0 @on_abort = on_abort end def call -> (finish, callback) { if finish on_abort.() return nil end return false if !array[@index] callback.(array[@index]) @index += 1 return true } end private attr_reader :array, :on_abort def objectify(object) if object.kind_of?(Hash) object.map { |k, v| v } else object.pretty_print_instance_variables.inject([]) do |coll, iv| coll << object.instance_variable_get(iv) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pull_stream-1.0.0 | lib/pull/source/values.rb |