Class: SycLink::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/syclink/importer.rb

Overview

To be subclassed for link importers.

Direct Known Subclasses

Chrome, FileImporter, Firefox, InternetExplorer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_to_bookmarks, opts = {}) ⇒ Importer

Creates a new Importer and sets the path to the bookmarks file. Opts may be :level which indicates to which levels tags should be imported and :tags to set tags during import.



17
18
19
20
# File 'lib/syclink/importer.rb', line 17

def initialize(path_to_bookmarks, opts = {})
  @path = path_to_bookmarks
  @opts = opts
end

Instance Attribute Details

#optsObject

Options for importing



12
13
14
# File 'lib/syclink/importer.rb', line 12

def opts
  @opts
end

#pathObject

Path to bookmarks file



10
11
12
# File 'lib/syclink/importer.rb', line 10

def path
  @path
end

Instance Method Details

Links returned as Link objects



36
37
38
39
40
41
# File 'lib/syclink/importer.rb', line 36

def links
  rows.map do |row|
    attributes = Link::ATTRS.dup - [:url]
    Link.new(row.shift, Hash[row.map { |v| [attributes.shift, v] }])
  end
end

#readObject

To be overridden! Read the raw data from the bookmarks file. The bookmarks file has to be provided during initialization with #initialize

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/syclink/importer.rb', line 25

def read
  raise NotImplementedError
end

#rowsObject

Links values returned in an Array. Default implementation returns values from #read.



31
32
33
# File 'lib/syclink/importer.rb', line 31

def rows
  read
end