Sha256: a0b57d6f681308338adf145415fbfa991cb9f32e7fb7875e4319a7897bae5de9

Contents?: true

Size: 554 Bytes

Versions: 24

Compression:

Stored size: 554 Bytes

Contents

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 = '-')
      ActiveSupport::Inflector.parameterize(self, sep)
    end
  end
  
  alias :to_slug   :parameterize
  alias :slugify   :parameterize
  alias :slugerize :parameterize
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
radiant-1.0.0.rc3 lib/plugins/string_extensions/lib/string_extensions.rb
kajam-1.0.3.rc2 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.0.0.rc2 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-1.0.0.rc1 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.2.4 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.2.2 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.2.1 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.2 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.9 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.8 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.7 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.6 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.5 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.4 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.3 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.2 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1.1 lib/plugins/string_extensions/lib/string_extensions.rb
radiantcms-couchrest_model-0.1 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-0.9.1 lib/plugins/string_extensions/lib/string_extensions.rb
radiant-0.8.2 lib/plugins/string_extensions/lib/string_extensions.rb