Class: NewsFireExport::Feedlist

Inherits:
Object
  • Object
show all
Defined in:
lib/newsfire_export.rb

Overview

Representation of the whole feedlist. Creating a new object of it basically does everything: It reads the feedlist from NewsFire, converts it into OPML. All that is left to do is call it’s to_s method ;)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {:origpath=>nil,:filter=>false}) ⇒ Feedlist

Returns a new instance of Feedlist.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/newsfire_export.rb', line 121

def initialize(options={:origpath=>nil,:filter=>false})
  origpath = options[:origpath]
  if origpath.nil?
    origpath = File.join(ENV['HOME'],'Library','Preferences','org.xlife.NewsFire.plist')
  end
  raise "NewsFire config file not found" if not File.exists?(origpath)
  @origpath=origpath
  @tmpxmlpath=File.join(ENV['HOME'],".nfe_#{Process.pid}.xml")
  @list = Array.new
  @groups = Array.new
  @feeds = Array.new
  @grouped_feeds = Hash.new
  @filter = options[:filter]
  import_origfile

  @plist['Feeds'].each do |feed|
    if feed['className']=='Group'
      @groups<<Group.new(feed,self)
    else
      if feed['isGrouped']==0
        next if feed['address'].nil?
        @feeds<<Feed.new(feed,self)
      else
        f = Feed.new(feed,self)
        @grouped_feeds[f.get_key]=f
      end
    end
  end
  @groups.each do |g|
    g.feeds.keys.each do |k|
      g.feeds[k]=@grouped_feeds[k]
    end
  end
end

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



120
121
122
# File 'lib/newsfire_export.rb', line 120

def filter
  @filter
end

Instance Method Details

#to_sObject

to_s dispatcher (currently only OPML supported)



157
158
159
# File 'lib/newsfire_export.rb', line 157

def to_s
  to_opml
end