Class: Tabcast::TabCastFeed
- Inherits:
-
Object
- Object
- Tabcast::TabCastFeed
- Defined in:
- lib/tabcast.rb
Instance Attribute Summary collapse
-
#feed ⇒ Object
readonly
Returns the value of attribute feed.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #formatted ⇒ Object
- #guidkillfile=(filename) ⇒ Object
-
#initialize(url, format) ⇒ TabCastFeed
constructor
A new instance of TabCastFeed.
- #killfile=(filename) ⇒ Object
Constructor Details
#initialize(url, format) ⇒ TabCastFeed
Returns a new instance of TabCastFeed.
27 28 29 30 31 32 33 |
# File 'lib/tabcast.rb', line 27 def initialize(url, format) @url = url @feed = RSS::Parser.parse(url, false) @template = Liquid::Template.parse(unescape(format)) @killlist = [] @guidkilllist = [] end |
Instance Attribute Details
#feed ⇒ Object (readonly)
Returns the value of attribute feed.
24 25 26 |
# File 'lib/tabcast.rb', line 24 def feed @feed end |
#prefix ⇒ Object
Returns the value of attribute prefix.
24 25 26 |
# File 'lib/tabcast.rb', line 24 def prefix @prefix end |
#suffix ⇒ Object
Returns the value of attribute suffix.
24 25 26 |
# File 'lib/tabcast.rb', line 24 def suffix @suffix end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
24 25 26 |
# File 'lib/tabcast.rb', line 24 def template @template end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
24 25 26 |
# File 'lib/tabcast.rb', line 24 def url @url end |
Instance Method Details
#formatted ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/tabcast.rb', line 43 def formatted vars = {} vars['channel_title'] = @feed.channel.title if @feed.channel.title vars['channel_description'] = @feed.channel.description if @feed.channel.description vars['channel_link'] = @feed.channel.link if @feed.channel.link vars['channel_language'] = @feed.channel.language if @feed.channel.language string = "" string += @prefix.render(vars) @feed.items.each do |i| if i.enclosure && i.enclosure.url if @killlist.include? i.enclosure.url killed = true end else killed = true end if i.guid if @guidkilllist.include? i.guid.to_s killed = true end end #killed = true if i.guid && (@guidkilllist.include? i.guid.to_s) unless killed if i.pubDate vars['utime'] = i.pubDate.strftime('%s') else vars['utime'] = nil end if i.title vars['title'] = i.title.chomp else vars['title'] = nil end if i.enclosure && i.enclosure.url vars['enclosure_url'] = i.enclosure.url else vars['enclosure_url'] = nil end if i. vars['itunes_author'] = i. if i. else vars['itunes_author'] = nil end if i. vars['author'] = i. else vars['guid'] = nil end string += @template.render(vars) end end string += @suffix.render(vars) string end |
#guidkillfile=(filename) ⇒ Object
111 112 113 |
# File 'lib/tabcast.rb', line 111 def guidkillfile=(filename) @guidkilllist = File.read(File.(filename)).split("\n") end |
#killfile=(filename) ⇒ Object
107 108 109 |
# File 'lib/tabcast.rb', line 107 def killfile=(filename) @killlist = File.read(File.(filename)).split("\n") end |