class ProgressBar::Calculators::Length
Attributes
Public Class Methods
Source
# File lib/ruby-progressbar/calculators/length.rb, line 8 def initialize(options = {}) self.length_override = options[:length] self.output = options[:output] self.current_length = nil end
Public Instance Methods
Source
# File lib/ruby-progressbar/calculators/length.rb, line 25 def calculate_length length_override || terminal_width || 80 end
Source
# File lib/ruby-progressbar/calculators/length.rb, line 14 def length current_length || reset_length end
Source
# 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
Source
# File lib/ruby-progressbar/calculators/length.rb, line 33 def length_override=(other) @length_override ||= ENV['RUBY_PROGRESS_BAR_LENGTH'] || other @length_override = @length_override.to_i if @length_override end
Source
# File lib/ruby-progressbar/calculators/length.rb, line 29 def reset_length self.current_length = calculate_length end