Class: RSSChannel
- Inherits:
-
Object
- Object
- RSSChannel
- Defined in:
- lib/core.rb
Overview
RSS Channel class
Instance Attribute Summary collapse
-
#feed ⇒ Object
Returns the value of attribute feed.
Instance Method Summary collapse
- #content_by_index(index) ⇒ Object
- #description_by_index(index) ⇒ Object
- #fetch_channel ⇒ Object
-
#initialize(channel_url) ⇒ RSSChannel
constructor
A new instance of RSSChannel.
- #items ⇒ Object
- #open_url_by_index(index) ⇒ Object
Constructor Details
#initialize(channel_url) ⇒ RSSChannel
Returns a new instance of RSSChannel.
13 14 15 16 17 18 |
# File 'lib/core.rb', line 13 def initialize(channel_url) @channel_url = channel_url @feed = nil fetch_channel end |
Instance Attribute Details
#feed ⇒ Object
Returns the value of attribute feed.
11 12 13 |
# File 'lib/core.rb', line 11 def feed @feed end |
Instance Method Details
#content_by_index(index) ⇒ Object
47 48 49 |
# File 'lib/core.rb', line 47 def content_by_index(index) Utils.html_to_text(description_by_index(index)) end |
#description_by_index(index) ⇒ Object
42 43 44 45 |
# File 'lib/core.rb', line 42 def description_by_index(index) item = @feed.items[index] item.description end |
#fetch_channel ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/core.rb', line 20 def fetch_channel URI.open(@channel_url) do |rss| @feed = RSS::Parser.parse(rss) # Utils.display_by_reader(@feed) end rescue OpenURI::HTTPError puts "[Request Error] #{@channel_url}" end |