Class: DaimonSkycrawlers::Filter::Base

Inherits:
Object
  • Object
show all
Includes:
ConfigMixin, LoggerMixin
Defined in:
lib/daimon_skycrawlers/filter/base.rb

Overview

Base class of filters.

You must implement #call in your filter and it must return true or false. If your filter returns true, processors can process given URL after your filter. Otherwise framework skips given URL to skip processors.

Direct Known Subclasses

DuplicateChecker, RobotsTxtChecker, UpdateChecker

Instance Method Summary collapse

Constructor Details

#initialize(storage: nil) ⇒ Base

Returns a new instance of Base.



18
19
20
21
# File 'lib/daimon_skycrawlers/filter/base.rb', line 18

def initialize(storage: nil)
  super()
  @storage = storage
end

Instance Method Details

#call(message) ⇒ true|false

Filter message

Override this method in subclass.

Parameters:

  • message (Hash)

    message can include anything

Returns:

  • (true|false)

    process the message if true otherwise skip message.

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/daimon_skycrawlers/filter/base.rb', line 39

def call(message)
  raise NotImplementedError, "Must implement this method in subclass"
end

#storageObject

Retrieve storage instance



26
27
28
# File 'lib/daimon_skycrawlers/filter/base.rb', line 26

def storage
  @storage ||= DaimonSkycrawlers::Storage::RDB.new
end