Sha256: 1a0f6288925c4d1530ec39d4abbd4b48766ebbc9f96b1840a84fd71075cbb33d

Contents?: true

Size: 845 Bytes

Versions: 4017

Compression:

Stored size: 845 Bytes

Contents

require 'ruby-progressbar/format/molecule'

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

4,017 entries across 4,017 versions & 27 rubygems

Version Path
cybrid_api_bank_ruby-0.122.66 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_organization_ruby-0.122.66 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_id_ruby-0.122.66 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_id_ruby-0.122.65 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_bank_ruby-0.122.65 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_organization_ruby-0.122.65 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_bank_ruby-0.122.64 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_id_ruby-0.122.64 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_organization_ruby-0.122.64 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_id_ruby-0.122.60 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_bank_ruby-0.122.60 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_organization_ruby-0.122.60 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_organization_ruby-0.122.59 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_bank_ruby-0.122.59 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_id_ruby-0.122.59 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_bank_ruby-0.122.58 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_organization_ruby-0.122.58 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_id_ruby-0.122.58 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_id_ruby-0.122.57 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb
cybrid_api_bank_ruby-0.122.57 vendor/bundle/ruby/3.3.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/format/string.rb