Module: FoodFishParser::Flat::AreaFao
- Defined in:
- lib/food_fish_parser/flat/area_fao.rb
Constant Summary collapse
- REGEX_CODE =
/ 0?\d{2} (?: (?: -0?\d{2} | (?: \/ | - | \s+ | ) [lIV]+ ) [a-d]? )? /ix
- REGEX =
/ \b FA[O0] \s* (?: -? (?:zone|gebied|area) )? \s* (?:nummer|nr\.?|,)? \s* ( #{REGEX_CODE} (?: (?: ,?\s*en\s* #{REGEX_CODE} ) | (?: \/ #{REGEX_CODE} )+ | (?: (?: ,\s* #{REGEX_CODE} )+ (?: ,?\s*en\s* #{REGEX_CODE} )? ) )? ) \b /ix
Class Method Summary collapse
Class Method Details
.find_all(text) ⇒ Object
29 30 31 32 |
# File 'lib/food_fish_parser/flat/area_fao.rb', line 29 def self.find_all(text) find_all_code_groups(text) .map {|a| { text: nil, fao_codes: a } } end |
.find_all_code_groups(text) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/food_fish_parser/flat/area_fao.rb', line 21 def self.find_all_code_groups(text) text .scan(REGEX) .flatten(1) .map {|s| s.split(/\s*(?: en | ,\s*en | , | \/ )\s*/xi) } .map {|a| a.map {|s| s.gsub(/\A0(\d{2})\z/, '\1') } } # normalize trailing zeroes end |