Class: MobME::Infrastructure::Utilities::FileOperations::MSISDNFilter
- Inherits:
-
Object
- Object
- MobME::Infrastructure::Utilities::FileOperations::MSISDNFilter
- Defined in:
- lib/mobme_support/file/msisdn_filter.rb
Overview
Filters for MSISDN-s in files.
Class Method Summary collapse
-
.filter(file_path, options_hash = {}) ⇒ Array
Filters input file for valid MSISDN-s.
Class Method Details
.filter(file_path, options_hash = {}) ⇒ Array
Filters input file for valid MSISDN-s.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mobme_support/file/msisdn_filter.rb', line 22 def filter(file_path, ={}) .recursively_symbolize_keys! .reverse_merge!({ :country => "IN", :format => "local" }) input_file_contents = get_file_contents(file_path) input_file_contents.scan(pattern()).map do |match| case [:format] when "local" match[2] when "country" settings[[:country]]['country_code'] + match[2] when "plus_country" "+#{settings[[:country]]['country_code']}#{match[2]}" when "international" settings[[:country]]['international_prefix'] + settings[[:country]]['country_code'] + match[2] else raise "Invalid :format value - must be one of 'local', 'country', 'plus_country', or 'international'." end end end |