Class: Cccode::CountryCode

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/cccode/models/country_code.rb

Class Method Summary collapse

Class Method Details

.insert_all(xml) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cccode/models/country_code.rb', line 6

def self.insert_all(xml)
  xml.css('Table').each_with_index do |_, idx|
    CountryCode.create(
      country: xml.css('Table/Name')[idx].text.strip,
      country_code: xml.css('Table/CountryCode')[idx].text.strip,
      currency: xml.css('Table/Currency')[idx].text.strip,
      currency_code: xml.css('Table/CurrencyCode')[idx].text.strip,
    )
  end
  true
end