Sha256: 437fd1e3b0f8635c6555c23eb576cf7ad25c53873bd34658dc384fd887dd6f55

Contents?: true

Size: 458 Bytes

Versions: 3

Compression:

Stored size: 458 Bytes

Contents

class TelegramOnSteroids::Updates
  attr_writer :stop

  def initialize(params)
    @params = params
  end

  def enum
    Enumerator.new do |y|
      loop do
        break if @stop

        updates = TelegramOnSteroids::Client.new.get_updates(@params)["result"]
        updates.each do |update|
          y << update
        end

        if updates.any?
          @params.merge! offset: updates.last["update_id"] + 1
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
telegram_on_steroids-0.1.2 lib/telegram_on_steroids/updates.rb
telegram_on_steroids-0.1.1 lib/telegram_on_steroids/updates.rb
telegram_on_steroids-0.1.0 lib/telegram_on_steroids/updates.rb