Module: Cms::Extensions::String
- Defined in:
- lib/cms/extensions/string.rb
Instance Method Summary collapse
- #indent(n = 0) ⇒ Object
- #markdown ⇒ Object
-
#pluralize_unless_one(count = nil) ⇒ String
Allows for conditional pluralization of names where object counts are not singular.
- #to_slug ⇒ Object
Instance Method Details
#indent(n = 0) ⇒ Object
4 5 6 |
# File 'lib/cms/extensions/string.rb', line 4 def indent(n=0) (" "*n.to_i) + self end |
#markdown ⇒ Object
7 8 9 |
# File 'lib/cms/extensions/string.rb', line 7 def markdown Cms.markdown? ? Markdown.new(self).to_html : "<strong>ERROR</strong>: Markdown Support Not Installed" end |
#pluralize_unless_one(count = nil) ⇒ String
Allows for conditional pluralization of names where object counts are not singular.
18 19 20 |
# File 'lib/cms/extensions/string.rb', line 18 def pluralize_unless_one(count=nil) count == 1 ? self : ActiveSupport::Inflector.pluralize(self) end |
#to_slug ⇒ Object
10 11 12 |
# File 'lib/cms/extensions/string.rb', line 10 def to_slug gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '-') end |