Class: Apolo::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/apolo/reader.rb

Overview

Readers are responsible for gathering data about a something specific that is a part of your system.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Reader

Returns a new instance of Reader.

Parameters:

  • config (Hash, #read)

    A hash containing any number of configurations that will be passed to the #setup method



9
10
11
12
13
14
# File 'lib/apolo/reader.rb', line 9

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

  setup(config.options)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/apolo/reader.rb', line 5

def data
  @data
end

Instance Method Details

#execute(*args) ⇒ Object

Called when the Reader must take action and gather all the data needed to be analyzed.

Raises:

  • (NotImplementedError)

    raised when method is not overriden.



28
29
30
# File 'lib/apolo/reader.rb', line 28

def execute(*args)
  raise NotImplementedError, 'You must implement the execute method for Reader to work correctly.'
end

#setup(*args) ⇒ Object

Called when the reader object is being constructed. Arguments can be everything the developer set in the creation of Reader.

Raises:

  • (NotImplementedError)

    raised when method is not overriden.



20
21
22
# File 'lib/apolo/reader.rb', line 20

def setup(*args)
  raise NotImplementedError, 'You must implement the setup method for Reader to work correctly.'
end