Sha256: 739cbd054ea040e25d4d92e7a0864f62ed6f75d3704f4c27f0ada4b078efef73

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

# Copyright (C) 2005-2006 Christopher Cyll
# Copyright (C) 2014-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.

# Scanners should respond to name(), match?(data), and decode(data).
# They should add an instance of themselves to the Scanner Registry
# on module load.

module Alexandria
  module Scanners
    def self.registry
      @registry ||= []
    end

    def self.register(scanner)
      registry.push(scanner)
    end

    def self.default_scanner
      registry.first
    end

    def self.find_scanner(name)
      registry.find { |scanner| scanner.name == name }
    end

    def self.each_scanner
      registry.each { |scanner| yield scanner }
    end

    private_class_method :registry
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alexandria-book-collection-manager-0.7.5 lib/alexandria/scanners.rb
alexandria-book-collection-manager-0.7.4 lib/alexandria/scanners.rb
alexandria-book-collection-manager-0.7.3 lib/alexandria/scanners.rb
alexandria-book-collection-manager-0.7.2 lib/alexandria/scanners.rb