Sha256: 8cbe6b7c491dc502bf1daf0d978b09a0f66384c406d85eb0e367b3a49758f2e5

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

module Rspamd
  module Check
    class Result
      attr_reader :data

      def self.parse(source)
        new JSON.parse(source)
      end

      def initialize(data = {})
        @data = data
      end

      def spam?
        score >= required_score
      end

      def ham?
        !spam?
      end

      def skipped?
        data.fetch("is_skipped")
      end

      def score
        data.fetch("score")
      end

      def required_score
        data.fetch("required_score")
      end

      def action
        data.fetch("action")
      end

      def symbols
        data.fetch("symbols")
      end

      def subject
        data["subject"]
      end

      def urls
        data["urls"] || []
      end

      def emails
        data["emails"] || []
      end

      def message_id
        data["message_id"]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspamd-ruby-1.0.0 lib/rspamd/check/result.rb