Class: BookmarkMachine::NetscapeFormatter

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

Overview

Formatter 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.

Defined Under Namespace

Classes: Writer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bookmarks) ⇒ NetscapeFormatter

Returns a new instance of NetscapeFormatter.



13
14
15
# File 'lib/bookmark_machine/netscape_formatter.rb', line 13

def initialize(bookmarks)
  @bookmarks = bookmarks
end

Instance Attribute Details

#bookmarksObject (readonly)

Returns the value of attribute bookmarks.



11
12
13
# File 'lib/bookmark_machine/netscape_formatter.rb', line 11

def bookmarks
  @bookmarks
end

Instance Method Details

#to_htmlObject Also known as: to_s

Returns an Array of Bookmark objects.



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

def to_html
  writer = Writer.new(StringIO.new)
  
  bookmarks.each{|b| writer << b }
  writer.done
  
  writer.io.string
end