Sha256: bdff1ff8a414f28c1759e3041a3614191186188f5e7c95b6c04856d7666e72b0

Contents?: true

Size: 781 Bytes

Versions: 4

Compression:

Stored size: 781 Bytes

Contents

class EntryParser

  def initialize(first_line, second_line)
    @first_line  = first_line
    @second_line = second_line
  end

  def parse
    number   = @first_line.search("[@class='title']")[0].inner_html.sub(".","").to_i
    link     = LinkInfoParser.new(@first_line.search("[@class='title']")[1]).parse
    voting   = VotingInfoParser.new(@first_line.search("td/center/a"), @second_line.search("[@class='subtext']")[0]).parse
    user     = UserInfoParser.new(@second_line.search("[@class='subtext']")[0]).parse
    comments = CommentsInfoParser.new(@second_line.search("[@class='subtext']")[0]).parse
    time     = TimeInfoParser.new(@second_line.search("[@class='subtext']").children[3]).parse
    return Entry.new(number, link, voting, user, comments, time)
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-hackernews-1.1.1 lib/ruby-hackernews/services/parsers/entry_parser.rb
ruby-hackernews-1.1.0 lib/ruby-hackernews/services/parsers/entry_parser.rb
ruby-hackernews-1.0.1 lib/ruby-hackernews/services/parsers/entry_parser.rb
ruby-hackernews-1.0.0 lib/HNAPI/services/parsers/entry_parser.rb