Class: AnyStyle::Normalizer::Page
- Inherits:
-
AnyStyle::Normalizer
- Object
- AnyStyle::Normalizer
- AnyStyle::Normalizer::Page
- Defined in:
- lib/anystyle/normalizer/page.rb
Instance Attribute Summary
Attributes inherited from AnyStyle::Normalizer
Instance Method Summary collapse
Methods inherited from AnyStyle::Normalizer
#append, #detect_language, #detect_scripts, #doi_extract, #each_value, #initialize, #keys_for, #map_values, #name, #skip?
Constructor Details
This class inherits a constructor from AnyStyle::Normalizer
Instance Method Details
#normalize(item, **opts) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/anystyle/normalizer/page.rb', line 6 def normalize(item, **opts) map_values(item) do |_, value| pages = case value when /(\d+)(?:\.(\d+))?(?:\((\d{4})\))?:(\d.*)/ # "volume.issue(year):pp" append(item, :volume, $1.to_i) append(item, :issue, $2.to_i) unless $2.nil? append(item, :year, $3.to_i) unless $3.nil? $4 else value end # TODO chap. 5, pp. 195-234. pages .gsub(/\p{Pd}+/, '–') .gsub(/[^\d,–]+/, ' ') .strip end end |