Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/marfa/helpers/classes/string.rb
Overview
Additional String functionality
Instance Method Summary collapse
-
#strip_tags! ⇒ String
Remove tags.
-
#to_class_name ⇒ String
Convert string like ‘category/list’ to CamelCase.
-
#to_underscore ⇒ String
Replaces all ‘/’ to ‘_’.
-
#to_url ⇒ String
Convert string to url part.
Instance Method Details
#strip_tags! ⇒ String
Remove tags
37 38 39 |
# File 'lib/marfa/helpers/classes/string.rb', line 37 def self.gsub(/<\/?[^>]*>/, '') # unless self.nil? end |
#to_class_name ⇒ String
Convert string like ‘category/list’ to CamelCase
15 16 17 18 19 |
# File 'lib/marfa/helpers/classes/string.rb', line 15 def to_class_name parts = downcase.split('/') parts.each(&:capitalize!) parts.join('').gsub(%r{-}, '') end |
#to_underscore ⇒ String
Replaces all ‘/’ to ‘_’
7 8 9 |
# File 'lib/marfa/helpers/classes/string.rb', line 7 def to_underscore downcase.gsub(%r{/}, '_') end |
#to_url ⇒ String
Convert string to url part
25 26 27 28 29 30 31 |
# File 'lib/marfa/helpers/classes/string.rb', line 25 def to_url val = self. val = val.gsub(':', '') val = val.gsub(' ', '-') val = val.gsub('/', '-') val.downcase end |