Class: ProgressBar::Calculators::Length
- Inherits:
-
Object
- Object
- ProgressBar::Calculators::Length
- Defined in:
- lib/ruby-progressbar/calculators/length.rb
Instance Attribute Summary collapse
-
#current_length ⇒ Object
Returns the value of attribute current_length.
-
#length_override ⇒ Object
Returns the value of attribute length_override.
Instance Method Summary collapse
- #calculate_length ⇒ Object
-
#initialize(options) ⇒ Length
constructor
A new instance of Length.
- #length ⇒ Object
- #length_changed? ⇒ Boolean
- #reset_length ⇒ Object
Constructor Details
#initialize(options) ⇒ Length
Returns a new instance of Length.
7 8 9 10 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 7 def initialize() self.length_override = [:length] self.current_length = nil end |
Instance Attribute Details
#current_length ⇒ Object
Returns the value of attribute current_length.
5 6 7 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 5 def current_length @current_length end |
#length_override ⇒ Object
Returns the value of attribute length_override.
4 5 6 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 4 def length_override @length_override end |
Instance Method Details
#calculate_length ⇒ Object
23 24 25 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 23 def calculate_length length_override || terminal_width || 80 end |
#length ⇒ Object
12 13 14 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 12 def length current_length || reset_length end |
#length_changed? ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 16 def length_changed? previous_length = current_length self.current_length = calculate_length previous_length != current_length end |
#reset_length ⇒ Object
27 28 29 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 27 def reset_length self.current_length = calculate_length end |