allows client application to override YAML hash
O(1) translation of 2-digit code to name
# File lib/usa_state_translater.rb, line 18 def self.translate_code_to_name(code) state = USA_STATES[code] raise NoStateError.new("[#{code}] IS NOT VALID") if state.nil? state["name"] end
O(N) translation from state name to 2-digit code
# File lib/usa_state_translater.rb, line 10 def self.translate_name_to_code(name) USA_STATES.each_pair do |key, value| return key if value["name"] == name end raise NoStateError.new("[#{name}] IS NOT VALID") end
Generated with the Darkfish Rdoc Generator 2.