module ActionView::Helpers
Public Instance Methods
country(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""})
click to toggle source
get country info given some params
# File lib/rails_country_select.rb, line 34 def country(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""}) result = [] COUNTRY_NUMS.zip(translate_countries, COUNTRY_ALPHA2S, COUNTRY_ALPHA3S).each do |country| if find_country(options, country) result = country end end result end
country_alpha2s(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""})
click to toggle source
get country alpha2s
# File lib/rails_country_select.rb, line 55 def country_alpha2s(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""}) country(options)[2] end
country_alpha3s(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""})
click to toggle source
get country alpha3s
# File lib/rails_country_select.rb, line 60 def country_alpha3s(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""}) country(options)[3] end
country_cod(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""})
click to toggle source
get country cod
# File lib/rails_country_select.rb, line 50 def country_cod(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""}) country(options)[0] end
country_name(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""})
click to toggle source
get country name
# File lib/rails_country_select.rb, line 45 def country_name(options = {:name => "", :num =>"", :alpha2s => "", :alpha3s => ""}) country(options)[1] end
Private Instance Methods
find_country(options, country)
click to toggle source
# File lib/rails_country_select.rb, line 71 def find_country(options, country) options[:num].to_i.eql?(country[0]) || options[:name].eql?(country[1]) || options[:alpha2s].eql?(country[2]) || options[:alpha3s].eql?(country[3]) end
translate_countries()
click to toggle source
# File lib/rails_country_select.rb, line 65 def translate_countries COUNTRY_ALPHA2S.zip(COUNTRY_NAMES).map do |code, name| I18n.t(code, :scope => :countries, :default => name) end end