Skip to content

Commit

Permalink
Rubocop autofixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paul committed May 28, 2024
1 parent 95d6856 commit 634b3ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions lib/progress_bar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def initialize(*args)
def increment!(count = 1)
@count += count
now = ::Time.now
if (now - @last_write) > 0.2 || @count >= max
write
@last_write = now
end
return unless (now - @last_write) > 0.2 || @count >= max

write
@last_write = now
end

def puts(text)
Expand Down Expand Up @@ -93,7 +93,7 @@ def print(str)
end

def clear!
print "\r" + " " * terminal_width + "\r"
print "\r" + (" " * terminal_width) + "\r"
end

def render(meter)
Expand Down Expand Up @@ -152,12 +152,13 @@ def bar_width

def non_bar_width
meters.reject { |meter| meter == :bar }.inject(0) do |width, meter|
width += width_of(meter) + 1
width + width_of(meter) + 1
end
end

def counter_width # [ 1/100]
max_width * 2 + 3
# [ 1/100]
def counter_width
(max_width * 2) + 3
end

def percentage_width
Expand All @@ -176,7 +177,8 @@ def eta_width
format_interval(eta).length + 2
end

def rate_width # [ 23.45/s]
# [ 23.45/s]
def rate_width
render_rate.length
end

Expand Down
2 changes: 1 addition & 1 deletion spec/with_progress_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

it "should give Enumerator" do
enum = (1..20).each_with_progress
expect(enum).to be_kind_of(Enumerator)
expect(enum).to be_a(Enumerator)
expect(bar.max).to eq 20
expect(bar.count).to eq 0

Expand Down

0 comments on commit 634b3ab

Please sign in to comment.