Class: BookmarkMachine::NetscapeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bookmark_machine/netscape_parser.rb

Overview

Parser for the Netscape Bookmark File format. Amusingly, the best documentation for the format comes from Microsoft.

https://msdn.microsoft.com/en-us/library/aa753582(v=vs.85).aspx

We live in interesting times.

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ NetscapeParser

Returns a new instance of NetscapeParser.



12
13
14
# File 'lib/bookmark_machine/netscape_parser.rb', line 12

def initialize(html)
  @html = html
end

Instance Method Details

#bookmarksObject

Returns an Array of Bookmark objects.



17
18
19
20
21
22
23
24
25
# File 'lib/bookmark_machine/netscape_parser.rb', line 17

def bookmarks
  @bookmarks ||= begin
    doc = BookmarkDocument.new
    parser = Nokogiri::HTML::SAX::Parser.new(doc)
    parser.parse(@html)
    
    doc.bookmarks
  end
end