Class: MetalArchives::Parsers::Parser
- Inherits:
-
Object
- Object
- MetalArchives::Parsers::Parser
- Defined in:
- lib/metal_archives/parsers/parser.rb
Overview
Parser base class
Class Method Summary collapse
-
.rewrite(input) ⇒ Object
Rewrite a URL.
-
.sanitize(input) ⇒ Object
Sanitize a string.
Class Method Details
.rewrite(input) ⇒ Object
Rewrite a URL
Return URI
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/metal_archives/parsers/parser.rb', line 32 def rewrite(input) return input unless MetalArchives.config.endpoint endpoint = URI(MetalArchives.config.endpoint) URI(input) .tap { |u| u.host = endpoint.host } .tap { |u| u.scheme = endpoint.scheme } .to_s end |
.sanitize(input) ⇒ Object
Sanitize a string
Return String
17 18 19 20 21 22 23 24 25 |
# File 'lib/metal_archives/parsers/parser.rb', line 17 def sanitize(input) return if input.blank? input .gsub(/^"/, "") .gsub(/"$/, "") .gsub(/[[:space:]]/, " ") .strip end |