Sha256: f97511c6af85dac9837155d7e3a9108ddb3695eafe263c45b2c6f748f06e8859

Contents?: true

Size: 537 Bytes

Versions: 3

Compression:

Stored size: 537 Bytes

Contents

module StringExtensions
  def symbolize
    self.gsub(/[^A-Za-z0-9]+/, "_").gsub(/(^_+|_+$)/, "").underscore.to_sym
  end
  
  def titlecase
    self.gsub(/((?:^|\s)[a-z])/) { $1.upcase }
  end
  
  def to_name(last_part = '')
    self.underscore.gsub('/', ' ').humanize.titlecase.gsub(/\s*#{last_part}$/, '')
  end
  
  def to_slug
    self.strip.downcase.gsub(/[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=+]+/, '-')
  end
  
  alias_method :slugify, :to_slug
  alias_method :slugerize, :to_slug
end

String.send :include, StringExtensions

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-0.7.2 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-0.7.0 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-0.7.1 lib/plugins/string_extensions/lib/string_extensions.rb