Class: ProgressBar::Format::Molecule

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-progressbar/format/molecule.rb

Constant Summary collapse

MOLECULES =
{
  :t => :title,
  :T => :title,
  :c => :progress,
  :C => :total,
  :p => :percentage,
  :P => :percentage_with_precision,
  :j => :justified_percentage,
  :J => :justified_percentage_with_precision,
  :a => :elapsed_time,
  :e => :estimated_time_with_unknown_oob,
  :E => :estimated_time_with_friendly_oob,
  :f => :estimated_time_with_no_oob,
  :B => :complete_bar,
  :b => :bar,
  :w => :bar_with_percentage,
  :i => :incomplete_space,
  :r => :rate_of_change,
  :R => :rate_of_change_with_precision,
}
BAR_MOLECULES =
%w{w B b i}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(letter) ⇒ Molecule

Returns a new instance of Molecule.



30
31
32
33
# File 'lib/ruby-progressbar/format/molecule.rb', line 30

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



27
28
29
# File 'lib/ruby-progressbar/format/molecule.rb', line 27

def key
  @key
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



28
29
30
# File 'lib/ruby-progressbar/format/molecule.rb', line 28

def method_name
  @method_name
end

Instance Method Details

#bar_molecule?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/ruby-progressbar/format/molecule.rb', line 35

def bar_molecule?
  BAR_MOLECULES.include? @key
end