class StateFinderService < ApplicationService
  def initialize(state)
    @state = state
  end

  def call
    values[@state.downcase.gsub(/[^A-Za-z]/, '')] || @state
  end

  private
    def values
      file = YAML.safe_load(File.open('states.yaml'))

      hash = {}

      file.each do |key, values|
        values.each { |v| hash[v] = key }
      end

      hash
    end
end
