Module: ActionView::Helpers

Defined in:
lib/rails_country_select.rb

Defined Under Namespace

Modules: FormOptionsHelper Classes: FormBuilder

Instance Method Summary collapse

Instance Method Details

#country(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""}) ⇒ Object

get country info given some params



33
34
35
36
37
38
39
40
41
# File 'lib/rails_country_select.rb', line 33

def country(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""})
  result = []
  COUNTRY_NUMS.zip(translate_countries, COUNTRY_ALPHA2S, COUNTRY_ALPHA3S).each do |country|
    if options[:num].to_i.eql?(country[0]) || options[:name].eql?(country[1]) || options[:alpha2s].eql?(country[2]) || options[:alpha3s].eql?(country[3])
     result = country
    end
  end
  result
end