Class: Markio::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/markio/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Parser

Returns a new instance of Parser.



5
6
7
8
# File 'lib/markio/parser.rb', line 5

def initialize(file)
  file = File.open(file) unless file.is_a? File
  @document = Nokogiri::HTML(file)
end

Instance Method Details

#parseObject



10
11
12
13
14
15
16
# File 'lib/markio/parser.rb', line 10

def parse
  bookmarks = []
  traverse(@document, []) do |bookmark|
    bookmarks << bookmark
  end
  bookmarks
end