Class: ProgressBar::Format::Molecule
- Inherits:
-
Object
- Object
- ProgressBar::Format::Molecule
- Defined in:
- lib/ruby-progressbar/format/molecule.rb
Constant Summary collapse
- MOLECULES =
{ :t => [:title_component, :title], :T => [:title_component, :title], :c => [:progressable, :progress], :C => [:progressable, :total], :u => [:progressable, :total_with_unknown_indicator], :p => [:percentage_component, :percentage], :P => [:percentage_component, :percentage_with_precision], :j => [:percentage_component, :justified_percentage], :J => [:percentage_component, :justified_percentage_with_precision], :a => [:time_component, :elapsed_with_label], :e => [:time_component, :estimated_with_unknown_oob], :E => [:time_component, :estimated_with_friendly_oob], :f => [:time_component, :estimated_with_no_oob], :l => [:time_component, :estimated_wall_clock], :B => [:bar_component, :complete_bar], :b => [:bar_component, :bar], :W => [:bar_component, :complete_bar_with_percentage], :w => [:bar_component, :bar_with_percentage], :i => [:bar_component, :incomplete_space], :r => [:rate_component, :rate_of_change], :R => [:rate_component, :rate_of_change_with_precision] }.freeze
- BAR_MOLECULES =
%w{W w B b i}.freeze
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
Instance Method Summary collapse
- #bar_molecule? ⇒ Boolean
- #full_key ⇒ Object
-
#initialize(letter) ⇒ Molecule
constructor
A new instance of Molecule.
- #lookup_value(environment, length = 0) ⇒ Object
- #non_bar_molecule? ⇒ Boolean
Constructor Details
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
30 31 32 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 30 def key @key end |
#method_name ⇒ Object
Returns the value of attribute method_name.
30 31 32 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 30 def method_name @method_name end |
Instance Method Details
#bar_molecule? ⇒ Boolean
38 39 40 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 38 def BAR_MOLECULES.include? key end |
#full_key ⇒ Object
46 47 48 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 46 def full_key "%#{key}" end |
#lookup_value(environment, length = 0) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 50 def lookup_value(environment, length = 0) component = environment.__send__(method_name[0]) if component.__send__(method_name[1], length).to_s else component.__send__(method_name[1]).to_s end end |
#non_bar_molecule? ⇒ Boolean
42 43 44 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 42 def ! end |