Skip to content

Commit

Permalink
Add missing functions to Rakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
BGMP committed Dec 13, 2022
1 parent 02d2253 commit 6259d13
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,14 @@ task :carboxes do
FileUtils.cp(carbox_path, "carboxes/#{car_ratings[car_rating]}/#{car_slug}.bmp")
end
end

def bytes_to_mb(bytes)
format_number((bytes.to_f / 2**20).round(2))
end

def format_number(number)
whole, decimal = number.to_s.split('.')
num_groups = whole.chars.to_a.reverse.each_slice(3)
whole_with_commas = num_groups.map(&:join).join(',').reverse
[whole_with_commas, decimal].compact.join('.')
end

0 comments on commit 6259d13

Please sign in to comment.