Module: Cul::Hydra::Solrizer::ModsFieldable::ClassMethods
- Defined in:
- lib/cul_hydra/solrizer/mods_fieldable.rb
Instance Method Summary collapse
- #map_field(field_key, map_key) ⇒ Object
- #map_value(field_key, value_key) ⇒ Object
- #maps_field?(field_key) ⇒ Boolean
- #normalize(t, strip_punctuation = false) ⇒ Object
- #value_mapper(maps = nil) ⇒ Object
Instance Method Details
#map_field(field_key, map_key) ⇒ Object
13 14 15 |
# File 'lib/cul_hydra/solrizer/mods_fieldable.rb', line 13 def map_field(field_key, map_key) value_mapper.map_field(field_key, map_key) end |
#map_value(field_key, value_key) ⇒ Object
17 18 19 |
# File 'lib/cul_hydra/solrizer/mods_fieldable.rb', line 17 def map_value(field_key, value_key) value_mapper.map_value(field_key, value_key) end |
#maps_field?(field_key) ⇒ Boolean
21 22 23 |
# File 'lib/cul_hydra/solrizer/mods_fieldable.rb', line 21 def maps_field?(field_key) value_mapper.maps_field? field_key end |
#normalize(t, strip_punctuation = false) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cul_hydra/solrizer/mods_fieldable.rb', line 24 def normalize(t, strip_punctuation=false) # strip whitespace n_t = t.dup.strip # collapse intermediate whitespace n_t.gsub!(/\s+/, ' ') # pull off paired punctuation, and any leading punctuation if strip_punctuation n_t = n_t.sub(/^\((.*)\)$/, "\\1") n_t = n_t.sub(/^\{(.*)\}$/, "\\1") n_t = n_t.sub(/^\[(.*)\]$/, "\\1") n_t = n_t.sub(/^"(.*)"$/, "\\1") n_t = n_t.sub(/^'(.*)'$/, "\\1") n_t = n_t.sub(/^<(.*)>$/, "\\1") #n_t = n_t.sub(/^\p{Ps}(.*)\p{Pe}/u, "\\1") n_t = n_t.sub(/^[[:punct:]]+/, '') # this may have 'created' leading/trailing space, so strip n_t.strip! end n_t end |
#value_mapper(maps = nil) ⇒ Object
9 10 11 |
# File 'lib/cul_hydra/solrizer/mods_fieldable.rb', line 9 def value_mapper(maps=nil) @value_mapper ||= ValueMapper.new(maps) end |