Class: SycLink::Importer
- Inherits:
-
Object
- Object
- SycLink::Importer
- Defined in:
- lib/syclink/importer.rb
Overview
To be subclassed for link importers.
Direct Known Subclasses
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.
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
#opts ⇒ Object
Options for importing
12 13 14 |
# File 'lib/syclink/importer.rb', line 12 def opts @opts end |
#path ⇒ Object
Path to bookmarks file
10 11 12 |
# File 'lib/syclink/importer.rb', line 10 def path @path end |
Instance Method Details
#links ⇒ Object
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 |
#read ⇒ Object
To be overridden! Read the raw data from the bookmarks file. The bookmarks file has to be provided during initialization with #initialize
25 26 27 |
# File 'lib/syclink/importer.rb', line 25 def read raise NotImplementedError end |
#rows ⇒ Object
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 |