class AnyStyle::Normalizer::Location

Public Instance Methods

normalize(item, **opts) click to toggle source
   # File lib/anystyle/normalizer/location.rb
 6 def normalize(item, **opts)
 7   map_values(item) do |_, value|
 8     location = strip value
 9 
10     if !item.key?(:publisher) && location.include?(':')
11       location, publisher = location.split(/\s*:\s*/)
12       append item, :publisher, publisher
13     end
14 
15     location
16   end
17 end
strip(string) click to toggle source
   # File lib/anystyle/normalizer/location.rb
19 def strip(string)
20   string.gsub(/^\p{^Alnum}+|\p{^Alnum}+$/, '')
21 end