Class: NewsFireExport::Feed

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

Overview

Representation of a feed that also holds everything that is needed for the OPML outline output

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, feedlist) ⇒ Feed

Returns a new instance of Feed.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/newsfire_export.rb', line 49

def initialize hash,feedlist
  if hash['address'].nil?
    pp hash
    raise "Not a feed"
  end
  @feedlist=feedlist
  @description = hash['comment']
  @xmlurl=hash['address']
  @htmlurl=hash['link']
  @name=hash['name']
  if @name.nil?
    raise NoNameException,"#{xmlurl} has no name"
    @name=@xmlurl
  end
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



48
49
50
# File 'lib/newsfire_export.rb', line 48

def description
  @description
end

#htmlurlObject (readonly)

Returns the value of attribute htmlurl.



48
49
50
# File 'lib/newsfire_export.rb', line 48

def htmlurl
  @htmlurl
end

#nameObject (readonly)

Returns the value of attribute name.



48
49
50
# File 'lib/newsfire_export.rb', line 48

def name
  @name
end

#xmlurlObject (readonly)

Returns the value of attribute xmlurl.



48
49
50
# File 'lib/newsfire_export.rb', line 48

def xmlurl
  @xmlurl
end

Instance Method Details

#get_keyObject

Tries to emulate the xmlUrl->filename conversion done by NewsFire



73
74
75
# File 'lib/newsfire_export.rb', line 73

def get_key
  @xmlurl.gsub(/^http:\/\//,'').gsub(/^www\./,'').gsub(/\//,'-').gsub('?','-')
end

#to_sObject

Generates by default an OPML outline or “” if the feedname starts with an underscore and filtering is enabled



67
68
69
70
# File 'lib/newsfire_export.rb', line 67

def to_s
  return "" if @feedlist.filter and @name=~/^_/
  to_opml
end