Sha256: 671159ccea89a0dc4e5cc321f65d7f302a7a6bbaa09acea30aeaac7876a2baf2

Contents?: true

Size: 428 Bytes

Versions: 8

Compression:

Stored size: 428 Bytes

Contents

module RubyHackernews

  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

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby-hackernews-1.4.0 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.3.7 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.3.6 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.3.5 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.3.3 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.3.2 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.3.1 lib/ruby-hackernews/services/parsers/link_info_parser.rb
ruby-hackernews-1.3.0 lib/ruby-hackernews/services/parsers/link_info_parser.rb