Sha256: 232f7cdc0ae235ea5ea3fd7fc0e18eab8b6e74333e73a712222f3ba6b7693ca3

Contents?: true

Size: 590 Bytes

Versions: 13

Compression:

Stored size: 590 Bytes

Contents

require 'stringex'

class String
  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

  unless methods.include?('parameterize')
    def parameterize(sep = '-')
      remove_formatting.downcase.replace_whitespace(sep).collapse(sep)
    end
  end
  
  alias :to_slug   :parameterize
  alias :slugify   :parameterize
  alias :slugerize :parameterize
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
trusty-cms-1.0.0 lib/string_extensions/string_extensions.rb
radiant-1.1.4 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.1.3 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.1.2 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.1.1 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.1.0 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.1.0.rc1 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.1.0.beta lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.0.1 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.1.0.alpha lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.0.0 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.0.0.rc5 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.0.0.rc4 lib/plugins/string_extensions/lib/string_extensions.rb