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
17 18 19 20 21 22 23 |
# File 'lib/imap/backup/naming.rb', line 17 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
7 8 9 10 11 12 13 14 15 |
# File 'lib/imap/backup/naming.rb', line 7 def self.to_local_path(name) name.gsub(INVALID_FILENAME_CHARACTER_MATCH) do |character| hex = character. codepoints[0]. to_s(16) "%#{hex};" end end |