Module: WorldWrap
- Defined in:
- lib/world_wrap.rb
Instance Method Summary collapse
- #cities(options = {}) ⇒ Object
- #countries(options = {}) ⇒ Object
- #is_invalid_key?(objects, value) ⇒ Boolean
- #states(options = {}) ⇒ Object
Instance Method Details
#cities(options = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/world_wrap.rb', line 17 def cities = {} return "Please pass a state name or code" if [:state].nil? || [:state].empty? state = [:state].downcase # return "not a valid key" if is_invalid_key?(STATES, state) TODO return "Need to store data for #{state} Or its not a state in the given list" unless CITIES.has_key?(state) CITIES[state] end |
#countries(options = {}) ⇒ Object
5 6 7 |
# File 'lib/world_wrap.rb', line 5 def countries = {} COUNTRIES end |
#is_invalid_key?(objects, value) ⇒ Boolean
25 26 27 28 |
# File 'lib/world_wrap.rb', line 25 def is_invalid_key?(objects, value) is_valid = objects.select{|object| object if [object[:name].downcase, object[:code].downcase].include?(value)} is_valid.empty? end |
#states(options = {}) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/world_wrap.rb', line 9 def states = {} return "Please pass a country name or code" if [:country].nil? || [:country].empty? country = [:country].downcase return "not a valid key" if is_invalid_key?(COUNTRIES, country) return "Need to save data for #{country}" unless STATES.has_key?(country) STATES[country] end |