-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix generating contact pages #45
Conversation
Remove class variables. Use only one instance of StaffInfo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had one suggestion but the code and functionality looks good.
body, | ||
"<li>Home Page: #{opts[:home_page]}</li>", | ||
opts[:home_page], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 68-84 are doing the same thing for each option. Could we dry it up like this?
[:email, :phone, :office_hours, :office_address, :home_page].each do |key|
append_str body, "<li>#{sym_to_title(key)}: #{opts[key]}</li>", opts[key]
end
The sym_to_title
method could look something like this.
def sym_to_title(symbol)
symbol.to_s.gsub("_", " ").split(/\W/).map(&:capitalize).join(" ")
end
I feel like this would make it easier to read as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I like that, but your sym_to_title isn't very easy to read. So I'll use Activesupport instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't realize we had ActiveSupport. That's definitely a better choice than using what I wrote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
Remove class variables.
Use only one instance of StaffInfo.
This fixes the contact page to contain contact info for only the given course. Also fixes so it works with
-m
in the task.