class HackerCurse::ForumArticle

Attributes

age[RW]
age_text[RW]
article_url[RW]
byline[RW]

byline is dump of text on top containing all the info on points, # of comments, nn hours aga

comment_count[RW]
comments[W]
comments_url[RW]
domain[RW]
domain_url[RW]
hash[R]
parent[RW]
points[RW]
submitter[RW]
submitter_url[RW]
title[RW]

Public Class Methods

new(h) click to toggle source
# File lib/hacker/curse/abstractsiteparser.rb, line 51
def initialize h
  @comments = nil
  @hash = h
  [:title, :article_url, :points, :comment_count, :comments_url, :age_text, :age,
   :submitter, :submitter_url, :domain, :domain_url, :byline].each do |sym|
    instance_variable_set("@#{sym.to_s}", h[sym]) if h.key? sym
  end
  if h.key? :comments
    c = h[:comments]
    @comments = Array.new
    c.each do |h|
      fc = ForumComment.new h
      @comments << fc
    end
  end
end

Public Instance Methods

[](sym) click to toggle source
# File lib/hacker/curse/abstractsiteparser.rb, line 79
def [](sym)
  @hash[sym]
end
comments() click to toggle source
# File lib/hacker/curse/abstractsiteparser.rb, line 68
def comments
  @comments || retrieve_comments(@comments_url)
end
each() { |e| ... } click to toggle source
# File lib/hacker/curse/abstractsiteparser.rb, line 71
def each
  comments.each do |e| yield(e) ; end
end
Also aliased as: each_comment
each_comment()
Alias for: each
keys() click to toggle source
# File lib/hacker/curse/abstractsiteparser.rb, line 82
def keys
  @hash.keys
end
retrieve_comments(url) click to toggle source
# File lib/hacker/curse/abstractsiteparser.rb, line 74
def retrieve_comments url
  raise "Parent must be set in order to retrieve comments " unless @parent
  @parent._retrieve_comments url
end
values() click to toggle source
# File lib/hacker/curse/abstractsiteparser.rb, line 85
def values
  @hash.values
end