Sha256: 9cd24677f8016da3cdcda5f290a743a067b56bf99cdfdca1d3ae73b01122ea8e

Contents?: true

Size: 379 Bytes

Versions: 8

Compression:

Stored size: 379 Bytes

Contents

class LinkInfoParser

  def initialize(link_element)
    @element = link_element
  end

  def parse
    link   = @element.search("a")[0]['href']
    title  = @element.search("a")[0].inner_html
    site_element = @element.search("span")
    site = site_element.inner_html.sub("(","").sub(")","").strip if site_element.any?
    return LinkInfo.new(title, link, site)
  end
  

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby-hackernews-1.2.1 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.2.0 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.1.3 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.1.2 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.1.1 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.1.0 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.0.1 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.0.0 lib/HNAPI/services/parsers/link_info_parser.rb