Sha256: 7bb1c20913125956603d694ac031ba6924abc149b603be28a7d6255989a40424

Contents?: true

Size: 788 Bytes

Versions: 13

Compression:

Stored size: 788 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)
    original_initialize(*args)
    @@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

13 entries across 13 versions & 1 rubygems

Version Path
narou-3.4.8 lib/web/progressbar4web.rb
narou-3.4.7.1 lib/web/progressbar4web.rb
narou-3.4.7 lib/web/progressbar4web.rb
narou-3.4.6.1 lib/web/progressbar4web.rb
narou-3.4.6 lib/web/progressbar4web.rb
narou-3.4.5 lib/web/progressbar4web.rb
narou-3.4.3 lib/web/progressbar4web.rb
narou-3.4.2 lib/web/progressbar4web.rb
narou-3.4.1 lib/web/progressbar4web.rb
narou-3.4.0 lib/web/progressbar4web.rb
narou-3.3.2 lib/web/progressbar4web.rb
narou-3.3.1 lib/web/progressbar4web.rb
narou-3.3.0 lib/web/progressbar4web.rb