Class: TelephoneNumber::PhoneDataImporter
- Inherits:
-
Object
- Object
- TelephoneNumber::PhoneDataImporter
- Defined in:
- lib/importers/phone_data_importer.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#override ⇒ Object
readonly
Returns the value of attribute override.
Instance Method Summary collapse
- #import! ⇒ Object
-
#initialize(file_name, override: false) ⇒ PhoneDataImporter
constructor
A new instance of PhoneDataImporter.
- #parse_main_data ⇒ Object
Constructor Details
#initialize(file_name, override: false) ⇒ PhoneDataImporter
Returns a new instance of PhoneDataImporter.
6 7 8 9 10 |
# File 'lib/importers/phone_data_importer.rb', line 6 def initialize(file_name, override: false) @data = {} @file = File.open(file_name) { |f| Nokogiri::XML(f) } @override = override end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/importers/phone_data_importer.rb', line 4 def data @data end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/importers/phone_data_importer.rb', line 4 def file @file end |
#override ⇒ Object (readonly)
Returns the value of attribute override.
4 5 6 |
# File 'lib/importers/phone_data_importer.rb', line 4 def override @override end |
Instance Method Details
#import! ⇒ Object
12 13 14 15 |
# File 'lib/importers/phone_data_importer.rb', line 12 def import! parse_main_data save_data_file end |
#parse_main_data ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/importers/phone_data_importer.rb', line 17 def parse_main_data file.css('territories territory').each do |territory| country_code = territory.attributes['id'].value.to_sym @data[country_code] ||= {} load_base_attributes(@data[country_code], territory) load_references(@data[country_code], territory) load_validations(@data[country_code], territory) load_formats(@data[country_code], territory) end end |