Module: GeoCombine::Formatting
- Included in:
- EsriOpenData, OGP
- Defined in:
- lib/geo_combine/formatting.rb
Overview
Mixin used for formatting metadata fields
Instance Method Summary collapse
-
#remove_lines(text) ⇒ String
Removes line breaks from a text input.
-
#sanitize(text) ⇒ String
Sanitizes html from a text input.
-
#sanitize_and_remove_lines(text) ⇒ String
Sanitizes and removes lines from a text block.
-
#sluggify(slug) ⇒ Object
slugs should be lowercase and only have a-z, A-Z, 0-9, and -.
Instance Method Details
#remove_lines(text) ⇒ String
Removes line breaks from a text input
17 18 19 |
# File 'lib/geo_combine/formatting.rb', line 17 def remove_lines(text) text.delete("\n") end |
#sanitize(text) ⇒ String
Sanitizes html from a text input
9 10 11 |
# File 'lib/geo_combine/formatting.rb', line 9 def sanitize(text) Sanitize.fragment(text) end |
#sanitize_and_remove_lines(text) ⇒ String
Sanitizes and removes lines from a text block
25 26 27 |
# File 'lib/geo_combine/formatting.rb', line 25 def sanitize_and_remove_lines(text) remove_lines(sanitize(text)) end |
#sluggify(slug) ⇒ Object
slugs should be lowercase and only have a-z, A-Z, 0-9, and -
30 31 32 |
# File 'lib/geo_combine/formatting.rb', line 30 def sluggify(slug) slug.gsub(/[^a-zA-Z0-9\-]/, '-').gsub(/[\-]+/, '-').downcase end |