Class: ProgressBar::Format::Molecule

Inherits:
Object
  • Object
show all
Defined in:
lib/progress_bar/format/molecule.rb

Constant Summary collapse

MOLECULES =
{
  :t => [:left_justified_title,               :title],
  :T => [:right_justified_title,              :title],
  :c => [:current_progress,                   :progress],
  :C => [:total_capacity,                     :total],
  :p => [:percentage_complete_as_integer,     :percentage],
  :P => [:percentage_complete_as_float,       :percentage_with_precision],
  :a => [:elapsed_time,                       :elapsed_time],
  :e => [:estimated_time_with_unknown,        :estimated_time_with_unknown_oob],
  :E => [:estimated_time_with_greater_than,   :estimated_time_with_friendly_oob],
  :f => [:force_estimated_time,               :estimated_time_with_no_oob],
  :B => [:complete_bar,                       :complete_bar],
  :b => [:bar,                                :bar],
  :w => [:bar_with_percentage,                :bar_with_percentage],
  :i => [:incomplete_space,                   :incomplete_space]
}
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.



27
28
29
30
# File 'lib/progress_bar/format/molecule.rb', line 27

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



23
24
25
# File 'lib/progress_bar/format/molecule.rb', line 23

def key
  @key
end

#method_argumentsObject (readonly)

Returns the value of attribute method_arguments.



25
26
27
# File 'lib/progress_bar/format/molecule.rb', line 25

def method_arguments
  @method_arguments
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



24
25
26
# File 'lib/progress_bar/format/molecule.rb', line 24

def method_name
  @method_name
end

Instance Method Details

#bar_molecule?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/progress_bar/format/molecule.rb', line 32

def bar_molecule?
  BAR_MOLECULES.include? @key
end