class String
Public Class Methods
file_ext(file_name, opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 43 def file_ext file_name, opts = {} File.extname(file_name)[1..-1].to_s.to_slug_param opts end
file_name(name, opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 47 def file_name name, opts = {} name = File.basename name ext = File.extname name File.basename(name, ext).to_s.to_slug_param opts end
slugged_filename(name, opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 53 def slugged_filename name, opts = {} name = File.basename name fname = self.file_name name, opts ext = self.file_ext name, opts return fname if ext.blank? [fname, ext].join('.') end
slugged_filepath(file_full_path, opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 62 def slugged_filepath file_full_path, opts = {} fname = slugged_filename file_full_path, opts file_full_path.split('/')[0...-1].push(fname).join '/' end
to_slug_param(str, opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 35 def to_slug_param str, opts = {} str = str.gsub(/\-{2,}/, '-').mb_chars sep = opts.delete(:sep) || '-' str = I18n::transliterate(str, opts) str = TheStringToSlug::basic_parametrize(str, sep) TheStringToSlug::parameterize(str, sep).to_s end
Public Instance Methods
slugged_filename(opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 23 def slugged_filename opts = {} self.class.slugged_filename(self, opts) end
slugged_filepath(opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 27 def slugged_filepath opts = {} self.class.slugged_filepath(self, opts) end
to_slug_param(opts = {})
click to toggle source
# File lib/the_string_to_slug.rb, line 19 def to_slug_param opts = {} self.class.to_slug_param(self, opts) end