module

YandexDisk::Parse

Parsers for the human-friendly scalars accepted in the config file.

Constants

SIZE_PATTERN = /\A\s*(\d+(?:\.\d+)?)\s*([a-zA-Z]*)\s*\z/
SIZE_UNITS = {"" => 1_i64, "b" => 1_i64, "k" => 1024_i64, "kb" => 1024_i64, "kib" => 1024_i64, "m" => 1024_i64 ** 2, "mb" => 1024_i64 ** 2, "mib" => 1024_i64 ** 2, "g" => 1024_i64 ** 3, "gb" => 1024_i64 ** 3, "gib" => 1024_i64 ** 3, "t" => 1024_i64 ** 4, "tb" => 1024_i64 ** 4, "tib" => 1024_i64 ** 4}
TIME_PATTERN = /\A\s*(\d+(?:\.\d+)?)\s*([a-zA-Z]*)\s*\z/
TIME_UNITS = {"ms" => 1.millisecond, "s" => 1.second, "m" => 1.minute, "h" => 1.hour, "d" => 1.day}

Class methods

bytes(value : String) : Int64

"16MB" => 16777216. Units are binary (KiB), bare numbers are bytes.

Source
duration(value : String) : Time::Span

"90s" => 90.seconds. A bare number is read as seconds.

Source
human_bytes(bytes : Int64) : String

1536 => "1.5 KiB", for log lines and the summary table.

Source
human_duration(span : Time::Span) : String
Source