Sha256: 5147d7303f3942904ef89931af3adcd70168f745a9155cb4a128769f9cd013d7

Contents?: true

Size: 1.6 KB

Versions: 2687

Compression:

Stored size: 1.6 KB

Contents

class   ProgressBar
module  Format
class   Molecule
  MOLECULES = {
    :t => [:title_comp,   :title],
    :T => [:title_comp,   :title],
    :c => [:progressable, :progress],
    :C => [:progressable, :total],
    :u => [:progressable, :total_with_unknown_indicator],
    :p => [:percentage,   :percentage],
    :P => [:percentage,   :percentage_with_precision],
    :j => [:percentage,   :justified_percentage],
    :J => [:percentage,   :justified_percentage_with_precision],
    :a => [:time,         :elapsed_with_label],
    :e => [:time,         :estimated_with_unknown_oob],
    :E => [:time,         :estimated_with_friendly_oob],
    :f => [:time,         :estimated_with_no_oob],
    :B => [:bar,          :complete_bar],
    :b => [:bar,          :bar],
    :W => [:bar,          :complete_bar_with_percentage],
    :w => [:bar,          :bar_with_percentage],
    :i => [:bar,          :incomplete_space],
    :r => [:rate,         :rate_of_change],
    :R => [:rate,         :rate_of_change_with_precision]
  }.freeze

  BAR_MOLECULES = %w{W w B b i}.freeze

  attr_accessor :key,
                :method_name

  def initialize(letter)
    self.key         = letter
    self.method_name = MOLECULES.fetch(key.to_sym)
  end

  def bar_molecule?
    BAR_MOLECULES.include? key
  end

  def non_bar_molecule?
    !bar_molecule?
  end

  def full_key
    "%#{key}"
  end

  def lookup_value(environment, length = 0)
    component = environment.__send__(method_name[0])

    if bar_molecule?
      component.__send__(method_name[1], length).to_s
    else
      component.__send__(method_name[1]).to_s
    end
  end
end
end
end

Version data entries

2,687 entries across 2,638 versions & 42 rubygems

Version Path
zilla-0.2.0 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
ory-keto-client-0.11.0.alpha0 vendor/bundle/ruby/2.5.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_id_ruby-0.62.44 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_organization_ruby-0.62.44 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_bank_ruby-0.62.44 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
mux_ruby-3.9.0 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_bank_ruby-0.62.43 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_organization_ruby-0.62.43 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_id_ruby-0.62.43 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_bank_ruby-0.62.41 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_organization_ruby-0.62.41 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_id_ruby-0.62.41 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_bank_ruby-0.62.40 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_id_ruby-0.62.40 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_organization_ruby-0.62.40 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_bank_ruby-0.62.39 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_organization_ruby-0.62.39 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_id_ruby-0.62.39 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
primary_connect_proto-0.19.0 vendor/bundle/ruby/3.0.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb
cybrid_api_bank_ruby-0.62.38 vendor/bundle/ruby/3.2.0/gems/ruby-progressbar-1.11.0/lib/ruby-progressbar/format/molecule.rb