Sha256: befb9305acbf856c8252139f62d03ff1b72406dc75b49d7719f3427f00b64aaf

Contents?: true

Size: 802 Bytes

Versions: 94

Compression:

Stored size: 802 Bytes

Contents

class   ProgressBar
module  Format
class   String < ::String
  MOLECULE_PATTERN = /%[a-zA-Z]/.freeze
  ANSI_SGR_PATTERN = /\e\[[\d;]+m/.freeze

  def displayable_length
    gsub(ANSI_SGR_PATTERN, '').length
  end

  def bar_molecule_placeholder_length
    @bar_molecule_placeholder_length ||= bar_molecules.size * 2
  end

  def non_bar_molecules
    @non_bar_molecules ||= molecules.select(&:non_bar_molecule?)
  end

  def bar_molecules
    @bar_molecules ||= molecules.select(&:bar_molecule?)
  end

  def molecules
    @molecules ||= begin
                      molecules = []

                      scan(MOLECULE_PATTERN) do |match|
                        molecules << Molecule.new(match[1, 1])
                      end

                      molecules
                    end
  end
end
end
end

Version data entries

94 entries across 55 versions & 13 rubygems

Version Path
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
passbase-1.1.0 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
passbase-1.0.3 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
paynow_sdk-1.1.0 vendor/bundle/ruby/2.7.0/gems/paynow_sdk-1.0.9/vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
paynow_sdk-1.1.0 vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
paynow_sdk-1.1.0 vendor/bundle/ruby/2.7.0/gems/paynow_sdk-1.0.9/vendor/cache/ruby/2.7.0/gems/paynow_sdk-1.0.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
paynow_sdk-1.1.0 vendor/bundle/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
paynow_sdk-1.1.0 vendor/bundle/ruby/2.7.0/gems/paynow_sdk-1.0.9/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
paynow_sdk-1.1.0 vendor/cache/ruby/2.7.0/gems/paynow_sdk-1.0.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb
paynow_sdk-1.0.9 vendor/cache/ruby/2.7.0/gems/paynow_sdk-1.0.0/vendor/cache/ruby/2.7.0/gems/ruby-progressbar-1.10.1/lib/ruby-progressbar/format/string.rb