This is really good stuff. I am going to get into nitty gritty to give you some items you could tweak:
- Your
Parsable
module is statically referencing two instance variables that are being created outside this module:@nokogiri_document
and@file
. That is a no-no. You want your module to be written in such a way that it needs to know nothing about the rest of your code. Thus, a better way would be to pass the nokogiri document and the file to the module as arguments. As in other words, yourParsable
module should be written in such a way that, if the names of these two instance variables were changed, there would be no need to change any of the code in yourParsable
module. - The
map_with_index
on line 5 in yourParsable
module is sweet. Nice work iterating over the DOM like this and delivering an array ofcomment
objects to yourpost
initialize method. - Heads up: Your
to_s
method on yourpost
class only prints the state of the ```comment