<commit_before>module LocationsNg
  class City
    @@all_cities

    class << self
      def all
        load_cities
      end

      def state_query(state)
        state == 'federal_capital_territory' ? 'fct' : state
      end

      def cities(state)
        load_cities
        state_query = self.state_query(state.downcase.gsub(' ', '_'))

        city_index = @@all_cities.index{ |c| c['alias'] == state_query }

        unless city_index.nil?
          return @@all_cities[city_index]['cities']
        end

        {message: "No cities found for '#{state}'", status: 404}
      end

      private
      def load_cities
        @@all_cities ||= YAML.load(File.read(files_location 'cities'))
      end

      def files_location(file)
        File.expand_path("../locations/#{file}.yml", __FILE__)
      end
    end
  end
end<commit_msg>Refactor City class to use new LoadFile class, and use instance vars.<commit_after>module LocationsNg
  class City
    @all_cities = LoadFile.read('cities')

    class << self
      def all
        @all_cities
      end

      def cities(state)
        state_query = state_query(state.downcase.gsub(' ', '_'))
        city_index = @all_cities.index{ |c| c['alias'] == state_query }

        unless city_index.nil?
          return @all_cities[city_index]['cities']
        end

        {message: "No cities found for '#{state}'", status: 404}
      end

      private

      def state_query(state)
        state == 'federal_capital_territory' ? 'fct' : state
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11132940406024885, 'fraction_numerical': 0.003929273084479371, 'mean_word_length': 2.293103448275862, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1274176', 'n_tokens_mistral': 508, 'n_tokens_neox': 472, 'n_words': 113}