Class: Alexandria::ImportFilter

Inherits:
Object
  • Object
show all
Extended by:
GetText
Includes:
GetText
Defined in:
lib/alexandria/ui/dialogs/import_dialog.rb,
lib/alexandria/import_library.rb

Overview

Copyright © 2004-2006 Laurent Sansonetti Copyright © 2011, 2016 Matijs van Zuijlen

Alexandria is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Alexandria is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Alexandria; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



25
26
27
# File 'lib/alexandria/import_library.rb', line 25

def message
  @message
end

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/alexandria/import_library.rb', line 25

def name
  @name
end

#patternsObject (readonly)

Returns the value of attribute patterns.



25
26
27
# File 'lib/alexandria/import_library.rb', line 25

def patterns
  @patterns
end

Class Method Details

.allObject



31
32
33
34
35
36
37
38
39
# File 'lib/alexandria/import_library.rb', line 31

def self.all
  [
    new(_('Autodetect'), ['*'], :import_autodetect),
    new(_('Archived Tellico XML (*.bc, *.tc)'),
        ['*.tc', '*.bc'], :import_as_tellico_xml_archive),
    new(_('ISBN List (*.txt)'), ['*.txt'], :import_as_isbn_list),
    new(_('GoodReads CSV'), ['*.csv'], :import_as_csv_file)
  ]
end

Instance Method Details

#invoke(library_name, filename) ⇒ Object



49
50
51
52
53
# File 'lib/alexandria/import_library.rb', line 49

def invoke(library_name, filename)
  puts "Selected: #{@message} -- #{library_name} -- #{filename}"
  Library.send(@message, library_name, filename,
               @on_iterate_cb, @on_error_cb)
end

#on_error(&on_error_cb) ⇒ Object



45
46
47
# File 'lib/alexandria/import_library.rb', line 45

def on_error(&on_error_cb)
  @on_error_cb = on_error_cb
end

#on_iterate(&on_iterate_cb) ⇒ Object



41
42
43
# File 'lib/alexandria/import_library.rb', line 41

def on_iterate(&on_iterate_cb)
  @on_iterate_cb = on_iterate_cb
end

#to_filefilterObject



22
23
24
25
26
27
# File 'lib/alexandria/ui/dialogs/import_dialog.rb', line 22

def to_filefilter
  filefilter = Gtk::FileFilter.new
  filefilter.name = name
  patterns.each { |x| filefilter.add_pattern(x) }
  filefilter
end