lib/jp_prefecture/prefecture.rb in jp_prefecture-0.3.0 vs lib/jp_prefecture/prefecture.rb in jp_prefecture-0.3.1
- old
+ new
@@ -92,12 +92,13 @@
protected
# 名前から都道府県コードを検索
def self.find_code_by_name(name)
- name.capitalize!
+ result = PREFECTURE_CODE_NAME.select { |_, v|
+ v.has_value?(name.capitalize)
+ }.first
- result = PREFECTURE_CODE_NAME.select { |_, v| v.has_value?(name) }.first
return if result.nil?
result[0]
end