module Net class NNTP class Group attr_reader :name, :article_count, :article_first, :article_last attr_reader :hi, :lo, :postingmode def initialize(name) @name = name @articles ||= Articles.new(self) #@articles.group = self @article_first = @article_last = @article_count = nil end # Set article_count, article_first, article_last (from GROUP command) # # Takes an array [count, first, last] as argument def article_info=(art_array) @article_count = art_array[0].to_i @article_first = art_array[1].to_i @article_last = art_array[2].to_i end def articles @articles end def articles=(articles) @articles = articles end # Sets hi and lo watermark alont with postingmode (from LIST ACTIVE command) def listinfo(hi, lo, postingmode) @hi = hi @lo = lo @postingmode = postingmode end def inspect "Group: #{@name} #{@article_count} #{@article_first} #{@article_last}" end class Articles attr_accessor :group def initialize(group) @articles ||=[] end # Stores articles in group attribute, using Net::NNTP::Article instances def build_from_over(over, format) article = Article.new article.overview_format = format article.overview(over) @articles << article end def length @articles.length end def <<(article) @articles << article end # Creates one Net::NNTP::Article instance, sets the group attribute to the # including group instances and adds the article to articles before returning it def create a = Article.new a.group = self.group @articles << a a end end end end end