From 51e2a04b9bd3c915d8e824f7c6885c2ef3b6c29b Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 24 May 2024 11:57:15 -0600 Subject: Sort communities in README --- bin/community | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/community b/bin/community index 305195d..84cf0bd 100755 --- a/bin/community +++ b/bin/community @@ -42,6 +42,10 @@ class Community @row.fetch(key.to_s.upcase) end + def <=>(other) + self.name <=> other.name + end + def create_content_in(root_dir) target_dir = "#{root_dir}/#{name.parameterize}" FileUtils.mkdir_p(target_dir, verbose: true) @@ -68,9 +72,16 @@ class Census yield Community.new(row) end end + + def create_content_in(dir) + erb = ERB.new(IO.read("templates/communities.md.erb"), trim_mode: "-") + IO.write("#{dir}/README.md", erb.result(binding)) + + find_all { |x| x[:class].include?("Residential") } + .each { |x| x.create_content_in(dir) } + end end Census .new("data/Census_by_Community_2019_20240524.csv") - .find_all { |x| x[:class].include?("Residential") } - .each { |x| x.create_content_in("yyc") } + .create_content_in("yyc") -- cgit v1.2.3