Skip to content

Commit

Permalink
complex method
Browse files Browse the repository at this point in the history
  • Loading branch information
rderoldan1 committed Aug 7, 2013
1 parent 3d7da08 commit ee6f577
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: ruby
before_install:
- gem install bundler
- gem --version
6 changes: 5 additions & 1 deletion lib/rails_country_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def country_select(method, options = {}, html_options = {})
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])
if find_country(options, country)
result = country
end
end
Expand Down Expand Up @@ -66,6 +66,10 @@ def translate_countries
I18n.t(code, :scope => :countries, :default => name)
end
end

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
end
end
end
Expand Down

0 comments on commit ee6f577

Please sign in to comment.