class String

Public Instance Methods

bn() click to toggle source
# File lib/rename2mac/libs.rb, line 27
def bn
        File.basename( self )
end
dn() click to toggle source
# File lib/rename2mac/libs.rb, line 23
def dn
        File.dirname( self )
end
escape_glob() click to toggle source

escape [] and {} character for Dir.glob to use

# File lib/rename2mac/libs.rb, line 3
def escape_glob
        self.gsub(/([\[\]\{\}\*\?\\])/, '\\\\\1')
end
print_diff() click to toggle source
to_m() click to toggle source
# File lib/rename2mac/libs.rb, line 7
def to_m
        # convert string to UTF8-MAC format
        self.encode('UTF8-MAC', 'UTF-8').force_encoding('UTF-8')

        # convert with extra function of replace invalid character to null
        #self.encode('UTF8-MAC', 'UTF-8', invalid: :replace, undef: :replace, replace: '')
end
to_u() click to toggle source
# File lib/rename2mac/libs.rb, line 15
def to_u
        # convert string to UTF-8 format
        self.encode('UTF-8', 'UTF8-MAC')

        # convert with extra function of replace invalid character to null
        #self.encode('UTF-8', 'UTF8-MAC', invalid: :replace, undef: :replace, replace: '')
end
um_different?() click to toggle source
# File lib/rename2mac/libs.rb, line 31
def um_different?
        # return if the string is different when converted to UTF8-MAC format
        self.unpack('H*') != self.to_m.unpack('H*')
end