-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Thank you for this.
Not a Ruby developer, far from it, but I needed sizes and mtime instead of ctime to write a pretty dir listing output , so I added the naive code below to yours. Sharing in case anyone else needs it.
74a75,90
>
> size_scale = " B"
> size_format = "%d"
> size = File.size(filename)
>
> if size > 1024 and size <= 1024*1024
> size /= 1024.0
> size_scale = " KiB"
> size_format = "%.1f"
> end
>
> if size > 1024*1024
> size /= 1024.0*1024.0
> size_scale = " MiB"
> size_format = "%.1f"
> end
79d94
< date = Time.parse(date)
83d97
< date = File.ctime(filename)
89c103
< 'date' => date,
---
> 'date' => File.mtime(filename),
90a105
> 'ext' => ext,
92c107,108
< 'url' => url
---
> 'url' => url,
> 'size' => size_format % size + size_scaleReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels