Class: ProgressBar::Format::String
- Inherits:
-
String
- Object
- String
- ProgressBar::Format::String
- Defined in:
- lib/ruby-progressbar/format/string.rb
Constant Summary collapse
- MOLECULE_PATTERN =
/%[a-zA-Z]/
- ANSI_SGR_PATTERN =
/\e\[[\d;]+m/
Instance Method Summary collapse
- #bar_molecule_placeholder_length ⇒ Object
- #bar_molecules ⇒ Object
- #displayable_length ⇒ Object
- #molecules ⇒ Object
- #non_bar_molecules ⇒ Object
Instance Method Details
#bar_molecule_placeholder_length ⇒ Object
11 12 13 |
# File 'lib/ruby-progressbar/format/string.rb', line 11 def @bar_molecule_placeholder_length ||= .size * 2 end |
#bar_molecules ⇒ Object
19 20 21 |
# File 'lib/ruby-progressbar/format/string.rb', line 19 def @bar_molecules ||= molecules.select(&:bar_molecule?) end |
#displayable_length ⇒ Object
7 8 9 |
# File 'lib/ruby-progressbar/format/string.rb', line 7 def displayable_length gsub(ANSI_SGR_PATTERN, '').length end |
#molecules ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby-progressbar/format/string.rb', line 23 def molecules @molecules ||= begin molecules = [] scan(MOLECULE_PATTERN) do |match| molecules << Molecule.new(match[1, 1]) end molecules end end |
#non_bar_molecules ⇒ Object
15 16 17 |
# File 'lib/ruby-progressbar/format/string.rb', line 15 def @non_bar_molecules ||= molecules.select(&:non_bar_molecule?) end |