Class: HackerCurse::ForumArticle
- Inherits:
-
Object
- Object
- HackerCurse::ForumArticle
- Defined in:
- lib/hacker/curse/abstractsiteparser.rb
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#age_text ⇒ Object
Returns the value of attribute age_text.
-
#article_url ⇒ Object
Returns the value of attribute article_url.
-
#byline ⇒ Object
byline is dump of text on top containing all the info on points, # of comments, nn hours aga.
-
#comment_count ⇒ Object
Returns the value of attribute comment_count.
- #comments ⇒ Object
-
#comments_url ⇒ Object
Returns the value of attribute comments_url.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#domain_url ⇒ Object
Returns the value of attribute domain_url.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#points ⇒ Object
Returns the value of attribute points.
-
#submitter ⇒ Object
Returns the value of attribute submitter.
-
#submitter_url ⇒ Object
Returns the value of attribute submitter_url.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #[](sym) ⇒ Object
- #each ⇒ Object (also: #each_comment)
-
#initialize(h) ⇒ ForumArticle
constructor
A new instance of ForumArticle.
- #keys ⇒ Object
- #retrieve_comments(url) ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(h) ⇒ ForumArticle
Returns a new instance of ForumArticle.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 |
Instance Attribute Details
#age ⇒ Object
Returns the value of attribute age.
41 42 43 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 41 def age @age end |
#age_text ⇒ Object
Returns the value of attribute age_text.
40 41 42 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 40 def age_text @age_text end |
#article_url ⇒ Object
Returns the value of attribute article_url.
36 37 38 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 36 def article_url @article_url end |
#byline ⇒ Object
byline is dump of text on top containing all the info on points, # of comments, nn hours aga
47 48 49 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 47 def @byline end |
#comment_count ⇒ Object
Returns the value of attribute comment_count.
38 39 40 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 38 def comment_count @comment_count end |
#comments ⇒ Object
68 69 70 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 68 def comments @comments || retrieve_comments(@comments_url) end |
#comments_url ⇒ Object
Returns the value of attribute comments_url.
39 40 41 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 39 def comments_url @comments_url end |
#domain ⇒ Object
Returns the value of attribute domain.
44 45 46 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 44 def domain @domain end |
#domain_url ⇒ Object
Returns the value of attribute domain_url.
45 46 47 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 45 def domain_url @domain_url end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
50 51 52 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 50 def hash @hash end |
#parent ⇒ Object
Returns the value of attribute parent.
48 49 50 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 48 def parent @parent end |
#points ⇒ Object
Returns the value of attribute points.
37 38 39 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 37 def points @points end |
#submitter ⇒ Object
Returns the value of attribute submitter.
42 43 44 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 42 def submitter @submitter end |
#submitter_url ⇒ Object
Returns the value of attribute submitter_url.
43 44 45 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 43 def submitter_url @submitter_url end |
#title ⇒ Object
Returns the value of attribute title.
35 36 37 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 35 def title @title end |
Instance Method Details
#[](sym) ⇒ Object
79 80 81 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 79 def [](sym) @hash[sym] end |
#each ⇒ Object Also known as: each_comment
71 72 73 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 71 def each comments.each do |e| yield(e) ; end end |
#keys ⇒ Object
82 83 84 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 82 def keys @hash.keys end |
#retrieve_comments(url) ⇒ Object
74 75 76 77 |
# 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 ⇒ Object
85 86 87 |
# File 'lib/hacker/curse/abstractsiteparser.rb', line 85 def values @hash.values end |