Improve method privacy

This commit is contained in:
Adam Hoyle 2021-08-24 21:27:43 +01:00
parent 94f9c2b86f
commit 0a3b052cf6

View file

@ -7,7 +7,10 @@ class Communities
@local_chapters[locale] = local_chapter_for(locale) @local_chapters[locale] = local_chapter_for(locale)
end end
def self.local_chapter_for(locale) class << self
protected
def local_chapter_for(locale)
@local_chapters_index = load_local_chapters @local_chapters_index = load_local_chapters
locale_dict = locale_dict_for(locale) locale_dict = locale_dict_for(locale)
localised_chapters = [] localised_chapters = []
@ -20,7 +23,7 @@ class Communities
localised_chapters localised_chapters
end end
def self.load_local_chapters def load_local_chapters
json_file = File.expand_path("node_modules/osm-community-index/dist/resources.json", Dir.pwd) json_file = File.expand_path("node_modules/osm-community-index/dist/resources.json", Dir.pwd)
community_index = JSON.parse(File.read(json_file)) community_index = JSON.parse(File.read(json_file))
local_chapters = [] local_chapters = []
@ -37,7 +40,7 @@ class Communities
local_chapters local_chapters
end end
def self.locale_dict_for(locale_in) def locale_dict_for(locale_in)
locale = locale_in.to_s.tr("-", "_") locale = locale_in.to_s.tr("-", "_")
full_local_path = File.expand_path("node_modules/osm-community-index/i18n/#{locale}.yaml", Dir.pwd) full_local_path = File.expand_path("node_modules/osm-community-index/i18n/#{locale}.yaml", Dir.pwd)
locale_dict = {} locale_dict = {}
@ -53,3 +56,4 @@ class Communities
locale_dict locale_dict
end end
end end
end