Class: Hacker::News::CommentTreeNode

Inherits:
Comment show all
Defined in:
lib/hacker/news/items.rb

Overview

A comment tree node with recursively-fetched replies. Inherits from Comment so callers can use is_a?(Comment) / pattern matching uniformly on the whole tree.

Instance Attribute Summary collapse

Attributes inherited from Comment

#kids, #parent, #text

Attributes inherited from Item

#by, #dead, #id, #time, #type

Instance Method Summary collapse

Methods inherited from Comment

#assign

Methods inherited from Item

#assign, from_hash

Constructor Details

#initialize(data, replies:) ⇒ CommentTreeNode

Returns a new instance of CommentTreeNode.

Parameters:

  • data (Hash)

    decoded comment payload.

  • replies (Array<CommentTreeNode>)


151
152
153
154
# File 'lib/hacker/news/items.rb', line 151

def initialize(data, replies:)
  super(data)
  @replies = replies
end

Instance Attribute Details

#repliesArray<CommentTreeNode> (readonly)

Returns child replies (already pruned of deleted nodes).

Returns:

  • (Array<CommentTreeNode>)

    child replies (already pruned of deleted nodes).



147
148
149
# File 'lib/hacker/news/items.rb', line 147

def replies
  @replies
end