Class: RubyHackernews::CommentsInfoParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-hackernews/services/parsers/comments_info_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(second_line) ⇒ CommentsInfoParser

Returns a new instance of CommentsInfoParser.



5
6
7
# File 'lib/ruby-hackernews/services/parsers/comments_info_parser.rb', line 5

def initialize(second_line)
  @second_line = second_line
end

Instance Method Details

#parseObject



9
10
11
12
13
14
15
16
# File 'lib/ruby-hackernews/services/parsers/comments_info_parser.rb', line 9

def parse
  return unless comments_link

  comments      = comments_link.text.split[0].to_i
  comments_page = comments_link['href']

  CommentsInfo.new(comments, comments_page)
end