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.
-
#output ⇒ Object
Returns the value of attribute output.
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.
8 9 10 11 12 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 8 def initialize( = {}) self.length_override = [:length] self.output = [:output] 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 |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 5 def output @output end |
Instance Method Details
#calculate_length ⇒ Object
25 26 27 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 25 def calculate_length length_override || terminal_width || 80 end |
#length ⇒ Object
14 15 16 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 14 def length current_length || reset_length end |
#length_changed? ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 18 def length_changed? previous_length = current_length self.current_length = calculate_length previous_length != current_length end |
#reset_length ⇒ Object
29 30 31 |
# File 'lib/ruby-progressbar/calculators/length.rb', line 29 def reset_length self.current_length = calculate_length end |