Zaru
Inherits Reference < Object
Constants
CHARACTER_FILTER = /[\x00-\x1F\/\\:\*\?\"<>\|]/i
FALLBACK_FILENAME = "file"
UNICODE_WHITESPACE = /[[:space:]]+/i
VERSION = "0.1.0"
WINDOWS_RESERVED_NAMES = ["CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"] of ::String
Constructors
new(filename : String, fallback, padding)
SourceClass methods
Instance methods
normalize
strip whitespace on beginning and end collapse intra-string whitespace into single spaces
sanitize
remove bad things!
- remove characters that aren't allowed cross-OS
- don't allow certain special filenames (issue on Windows)
- don't allow filenames to start with a dot
- don't allow empty filenames
this renormalizes after filtering in order to collapse whitespace
to_s
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO) which can be overridden for custom implementations.
Also see #inspect.
truncate
cut off at 255 characters optionally provide a padding, which is useful to make sure there is room to add a file extension later