Method: FbRuby::Comments#get_reply

Defined in:
lib/FbRuby/comments.rb

#get_reply(limit = 10) ⇒ Array<Comments>, C

Dapatkan balasan dari komentar

Parameters:

  • limit (Integer) (defaults to: 10)

    Limit maksimal balasan yang akan di ambil

Returns:



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/FbRuby/comments.rb', line 138

def get_reply(limit = 10)
  balasanList = []
  balasan = @html.at_xpath("//a[starts-with(@href,'/comment/replies') and contains(@href,'count')]")

  unless balasan.nil?
    html = @sessions.get(URI.join(@url,balasan['href'])).parse_html
    for i in html.css("h3:not([class])")[1...]
      div_comment = i.ancestors('div[class][id]').find { |div| div['id'] =~ /^\d+$/ }
      div_comment = i.ancestors.css('div:not([class]):not([id]:not([role]))')[2] if div_comment.nil?
      next if div_comment.nil?
      balasanList << FbRuby::Comments.new(nokogiriObj: div_comment, request_session: @sessions)
    end        
  end

  return balasanList
end