Class: SevenBankFxRate::Parser
- Inherits:
-
Object
- Object
- SevenBankFxRate::Parser
- Defined in:
- lib/seven_bank_fx_rate/parser.rb
Overview
Parses xml response content and convert to ruby objects
Instance Method Summary collapse
-
#countries ⇒ Object
Parses the <countries> section in original xml response.
-
#initialize(response) ⇒ Parser
constructor
A new instance of Parser.
-
#meta ⇒ Object
Parses the <header> section in original xml response.
Constructor Details
Instance Method Details
#countries ⇒ Object
Parses the <countries> section in original xml response
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/seven_bank_fx_rate/parser.rb', line 29 def countries countries = [] return countries unless @root @root.elements.each('countries/country') do |country_tag| country = Elements::Country.new %w[country_code country_name].each do |attr| country_tag.elements.each(attr.split('_').join) do |e| country.send("#{attr}=".to_sym, e.text.strip) end end country.currencies = currencies country_tag countries << country end countries end |
#meta ⇒ Object
Parses the <header> section in original xml response
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/seven_bank_fx_rate/parser.rb', line 15 def = Elements::Meta.new return unless @root %w[create_date apply_date apply_time data_count].each do |attr| @root.elements.each("header/#{attr.split('_').join}") do |e| .send("#{attr}=".to_sym, e.text.strip) end end end |