Sha256: 8ec4d22827e14cae446f5cbaa058c4d7326249afc97d3041313d1c2875ea7ed3

Contents?: true

Size: 802 Bytes

Versions: 12

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

#
# Copyright 2013 whiteleaf. All rights reserved.
#

require_relative "../progressbar"

#
# コンソール用のプログレスバーはWEB UIでは使えないため置き換える
#
class ProgressBar
  def self.push_server=(server)
    @@push_server = server
  end

  alias :original_initialize :initialize

  def initialize(*args, **opt)
    original_initialize(*args, **opt)
    @@push_server.send_all("progressbar.init" => { target_console: io.target_console })
  end

  def output(num)
    percent = calc_ratio(num) * 100
    @@push_server.send_all("progressbar.step" => {
      percent: percent,
      target_console: io.target_console
    })
  end

  def clear
    @@push_server.send_all("progressbar.clear" => { target_console: io.target_console })
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
narou-3.9.1 lib/web/progressbar4web.rb
narou-3.9.0 lib/web/progressbar4web.rb
narou-3.8.2 lib/web/progressbar4web.rb
narou-3.8.1 lib/web/progressbar4web.rb
narou-3.8.0 lib/web/progressbar4web.rb
narou-3.7.2 lib/web/progressbar4web.rb
narou-3.7.1 lib/web/progressbar4web.rb
narou-3.7.0 lib/web/progressbar4web.rb
narou-3.6.0 lib/web/progressbar4web.rb
narou-3.5.1 lib/web/progressbar4web.rb
narou-3.5.0.1 lib/web/progressbar4web.rb
narou-3.5.0 lib/web/progressbar4web.rb