class Rssop::Rssop
Attributes
content[R]
Public Class Methods
new( index )
click to toggle source
# File lib/rsstsvop/rss.rb, line 7 def initialize( index ) hash = @@config[index] pp hash @url = hash[:url] @user = hash[:user] @passwd = hash[:passwd] @fname = hash[:fname] end
Public Instance Methods
get()
click to toggle source
# File lib/rsstsvop/rss.rb, line 16 def get if @user != nil and @passwd != nil @content = open(@url, http_basic_authentication: [@user, @passwd]).read else @content = open(@url).read end self end
parse( validation=true )
click to toggle source
# File lib/rsstsvop/rss.rb, line 42 def parse( validation=true ) @rss = RSS::Parser.parse(@content,validation) self end
print_all_items()
click to toggle source
# File lib/rsstsvop/rss.rb, line 54 def print_all_items @rss.items.map{|item| puts item.pubDate.strftime( "%Y/%m/%d" ) puts item.category.content puts item.title puts item.link puts item.description puts } end
print_title_list()
click to toggle source
# File lib/rsstsvop/rss.rb, line 48 def print_title_list @rss.channel.items.each do |x| puts x.title end end
read_from_file()
click to toggle source
# File lib/rsstsvop/rss.rb, line 34 def read_from_file File.open( @fname , 'r' , {encoding: Encoding::UTF_8} ){|f| @content = f.read } self end
save()
click to toggle source
# File lib/rsstsvop/rss.rb, line 26 def save File.open( @fname , 'w' , {encoding: Encoding::UTF_8} ){|f| f.write( @content ) } self end