Class: Omnom::Source::Xkcd::Default

Inherits:
Base
  • Object
show all
Defined in:
lib/omnom/source/xkcd/default.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #feed_key, #key, #options, #settings, #source_id

Instance Method Summary collapse

Methods inherited from Base

#after_initialize, config, configure, cron, every, feed_url, full_key, guid_namespace, icon, icon_from_url, inherited, #initialize, key, required_config, required_options, #update, url

Methods included from ParserMethods

#html_to_text

Constructor Details

This class inherits a constructor from Omnom::Source::Base

Instance Method Details

#get_raw_postsObject



8
9
10
# File 'lib/omnom/source/xkcd/default.rb', line 8

def get_raw_posts
  @page.search('feed > entry')
end

#post_attributes(node) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/omnom/source/xkcd/default.rb', line 12

def post_attributes(node)
  image_node = node.find('summary').parse_text.find('img')
  image_url = image_node.attr('src')
  url = node.find('link').url
  guid = url[/\/(\d+)\/$/, 1]
  {
    title: node.find('title').text,
    description: html_to_text(image_node.attr('title')),
    guid: guid,
    url: url,
    published_at: node.find('updated').time,
    thumbnail_url: image_url,
    author_name: 'Randall Munroe',
    author_url: 'http://xkcd.com/about/',
    other: {
      images: [{
        page_url: url,
        image_url: image_url  
      }]
    }
  }
end