Class: MediumSyncer
- Inherits:
-
PerNodeSyncer
- Object
- AbstractSyncer
- PerNodeSyncer
- MediumSyncer
- Defined in:
- lib/syncers/medium_syncer.rb
Constant Summary
Constants included from NodeAttrModule
Instance Method Summary collapse
Methods inherited from PerNodeSyncer
Methods included from NodeAttrModule
Methods inherited from AbstractSyncer
#_fetch_html, #gen_html, #initialize
Constructor Details
This class inherits a constructor from AbstractSyncer
Instance Method Details
#_handle_node(node) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/syncers/medium_syncer.rb', line 19 def _handle_node(node) case node.name when "figure" img_nodes = node.css('img') node = img_nodes[-1] if img_nodes # to make sure image scales right node.remove_attribute('width') node.remove_attribute('height') end node.to_html end |
#get_article_nodes ⇒ Object
override
11 12 13 14 15 16 17 |
# File 'lib/syncers/medium_syncer.rb', line 11 def get_article_nodes page_html = self._fetch_html article = Nokogiri::HTML(page_html).xpath(self.get_article_xpath) # Medium embeds Author section, which is not needed for article article.children[1..] end |
#get_article_xpath ⇒ Object
6 7 8 |
# File 'lib/syncers/medium_syncer.rb', line 6 def get_article_xpath '//article/div/section/div/div' end |