Class: SycLink::Importer
- Inherits:
-
Object
- Object
- SycLink::Importer
- Defined in:
- lib/syclink/importer.rb
Overview
To be subclassed for link importers.
Direct Known Subclasses
Constant Summary collapse
- CLEANER =
REGEX to clean tags and url names
/[^a-zA-Zäöü& ]/
Instance Attribute Summary collapse
-
#opts ⇒ Object
Options for importing.
-
#path ⇒ Object
Path to bookmarks file.
Instance Method Summary collapse
-
#initialize(path_to_bookmarks, opts = {}) ⇒ Importer
constructor
Creates a new Importer and sets the path to the bookmarks file.
-
#links ⇒ Object
Links returned as Link objects.
-
#read ⇒ Object
To be overridden! Read the raw data from the bookmarks file.
-
#rows ⇒ Object
Links values returned in an Array.
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.
19 20 21 22 |
# File 'lib/syclink/importer.rb', line 19 def initialize(path_to_bookmarks, opts = {}) @path = path_to_bookmarks @opts = opts end |
Instance Attribute Details
#opts ⇒ Object
Options for importing
14 15 16 |
# File 'lib/syclink/importer.rb', line 14 def opts @opts end |
#path ⇒ Object
Path to bookmarks file
12 13 14 |
# File 'lib/syclink/importer.rb', line 12 def path @path end |
Instance Method Details
#links ⇒ Object
Links returned as Link objects
38 39 40 41 42 43 |
# File 'lib/syclink/importer.rb', line 38 def links rows.map do |row| attributes = Link::ATTRS.dup - [:url] Link.new(row.shift, Hash[row.map { |v| [attributes.shift, v] }]) end end |
#read ⇒ Object
To be overridden! Read the raw data from the bookmarks file. The bookmarks file has to be provided during initialization with #initialize
27 28 29 |
# File 'lib/syclink/importer.rb', line 27 def read raise NotImplementedError end |
#rows ⇒ Object
Links values returned in an Array. Default implementation returns values from #read.
33 34 35 |
# File 'lib/syclink/importer.rb', line 33 def rows read end |