module Madness::StringRefinements
Public Instance Methods
remove(regex)
click to toggle source
# File lib/madness/refinements/string_refinements.rb, line 6 def remove(regex) gsub regex, '' end
to_href()
click to toggle source
# File lib/madness/refinements/string_refinements.rb, line 10 def to_href Addressable::URI.escape self end
to_label()
click to toggle source
This is here so we can have one place that defines how to convert a string (usually a filename without .md extension, or a folder name) to a label. It is used by different navigation elements in madness, and ucrrently just removes any numbers followed by a dot at the beginning of the string, in order to allow “The Invisible Sorting Hand”.
# File lib/madness/refinements/string_refinements.rb, line 24 def to_label remove(/^\d+\.\s+/).remove(/\.md$/) end
to_slug()
click to toggle source
# File lib/madness/refinements/string_refinements.rb, line 14 def to_slug downcase.strip.gsub(/[^[:alnum:]]/, '-').squeeze('-').remove(/(^-|-$)/) end