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,
  :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.



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

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



25
26
27
# File 'lib/ruby-progressbar/format/molecule.rb', line 25

def key
  @key
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



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

def method_name
  @method_name
end

Instance Method Details

#bar_molecule?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/ruby-progressbar/format/molecule.rb', line 33

def bar_molecule?
  BAR_MOLECULES.include? @key
end