Class: Imap::Backup::Naming
- Inherits:
-
Object
- Object
- Imap::Backup::Naming
- Defined in:
- lib/imap/backup/naming.rb
Constant Summary collapse
- INVALID_FILENAME_CHARACTERS =
":%;".freeze
- INVALID_FILENAME_CHARACTER_MATCH =
/([#{INVALID_FILENAME_CHARACTERS}])/.freeze
Class Method Summary collapse
- .from_local_path(name) ⇒ Object
-
.to_local_path(name) ⇒ Object
‘*_path` functions treat `/` as an acceptable character.
Class Method Details
.from_local_path(name) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/imap/backup/naming.rb', line 19 def self.from_local_path(name) name.gsub(/%(.*?);/) do ::Regexp.last_match(1). to_i(16). chr("UTF-8") end end |
.to_local_path(name) ⇒ Object
‘*_path` functions treat `/` as an acceptable character
9 10 11 12 13 14 15 16 17 |
# File 'lib/imap/backup/naming.rb', line 9 def self.to_local_path(name) name.gsub(INVALID_FILENAME_CHARACTER_MATCH) do |character| hex = character. codepoints[0]. to_s(16) "%#{hex};" end end |