ClearBlog/lib/utils/string_short_name.rb

24 lines
365 B
Ruby

module StringShortname
refine String do
def file_to_slug
gsub(/\.md$/, '')
end
def file_to_slug!
gsub!(/\.md$/, '')
end
def slug_to_file
end_with_md? ? self : gsub(/$/, '.md')
end
def slug_to_file!
end_with_md? ? self : gsub!(/$/, '.md')
end
def end_with_md?
end_with? ".md"
end
end
end