module Scruber::Helpers::DictionaryReader
Public Class Methods
[](label)
click to toggle source
# File lib/scruber/helpers/dictionary_reader.rb, line 23 def [](label) _registered_types[label] end
_registered_types()
click to toggle source
# File lib/scruber/helpers/dictionary_reader.rb, line 27 def _registered_types @registered_types ||= {} end
add(label, claz)
click to toggle source
# File lib/scruber/helpers/dictionary_reader.rb, line 15 def add(label, claz) unless claz.instance_methods.include?(:read) raise NoMethodError, "read is not declared in the #{claz.inspect}" end _registered_types[label] = claz end
read(file_path, file_type, options) { |obj| ... }
click to toggle source
# File lib/scruber/helpers/dictionary_reader.rb, line 5 def read(file_path, file_type, options) if _registered_types.keys.include?(file_type.to_sym) _registered_types[file_type.to_sym].new(file_path).read(options) do |obj| yield obj end else raise "Unsupported type, supported types #{_registered_types.keys}" end end