summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2024-05-24 11:57:15 -0600
committermo khan <mo@mokhan.ca>2024-05-24 11:57:15 -0600
commit51e2a04b9bd3c915d8e824f7c6885c2ef3b6c29b (patch)
treef2d63d9face1b68edfbabe4e11bab8c8900bff97 /bin
parentf790b3e347533447b0f07c0a03d34e1156ca770b (diff)
Sort communities in README
Diffstat (limited to 'bin')
-rwxr-xr-xbin/community15
1 files changed, 13 insertions, 2 deletions
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")