Class: ProgressBar::Format::Molecule
- Inherits:
-
Object
- Object
- ProgressBar::Format::Molecule
- Defined in:
- lib/ruby-progressbar/format/molecule.rb
Constant Summary collapse
- 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, :bar_with_percentage], :i => [:bar, :incomplete_space], :r => [:rate, :rate_of_change], :R => [:rate, :rate_of_change_with_precision] }.freeze
- BAR_MOLECULES =
%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.
28 29 30 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 28 def key @key end |
#method_name ⇒ Object
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
36 37 38 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 36 def BAR_MOLECULES.include? key end |
#full_key ⇒ Object
44 45 46 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 44 def full_key "%#{key}" end |
#lookup_value(environment, length = 0) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 48 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
40 41 42 |
# File 'lib/ruby-progressbar/format/molecule.rb', line 40 def ! end |