Sha256: cad4feb44444d3aad559d5bb2f0dfd74a3fd0f3f2aa092329d9a90f5fcd10dce

Contents?: true

Size: 826 Bytes

Versions: 3

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

module Apullo
  module Fingerprint
    class Base
      attr_reader :target

      def initialize(target)
        @target = target
        @results = nil
      end

      def name
        self.class.to_s.split("::").last.to_s.downcase
      end

      def results
        return @results if @results

        with_error_handling do
          @results ||= build_results
        end
        @results
      end

      private

      def with_error_handling
        yield
      rescue StandardError => e
        @results = { error: e.to_s }
      end

      def build_results
        raise NotImplementedError, "You must implement #{self.class}##{__method__}"
      end

      class << self
        def inherited(child)
          Apullo.fingerprints << child
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apullo-0.2.0 lib/apullo/fingerprints/base.rb
apullo-0.1.5 lib/apullo/fingerprints/base.rb
apullo-0.1.4 lib/apullo/fingerprints/base.rb