Class: DataMiner::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/data_miner/process.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, position_in_run, method_name_or_block_description, &block) ⇒ Process

Returns a new instance of Process.



8
9
10
11
12
13
14
15
16
17
# File 'lib/data_miner/process.rb', line 8

def initialize(base, position_in_run, method_name_or_block_description, &block)
  @base = base
  @position_in_run = position_in_run
  if block_given?
    @block_description = method_name_or_block_description
    @block = block
  else
    @method_name = method_name_or_block_description
  end
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



3
4
5
# File 'lib/data_miner/process.rb', line 3

def base
  @base
end

#blockObject

Returns the value of attribute block.



5
6
7
# File 'lib/data_miner/process.rb', line 5

def block
  @block
end

#block_descriptionObject

Returns the value of attribute block_description.



5
6
7
# File 'lib/data_miner/process.rb', line 5

def block_description
  @block_description
end

#method_nameObject

Returns the value of attribute method_name.



4
5
6
# File 'lib/data_miner/process.rb', line 4

def method_name
  @method_name
end

#position_in_runObject

Returns the value of attribute position_in_run.



3
4
5
# File 'lib/data_miner/process.rb', line 3

def position_in_run
  @position_in_run
end

Instance Method Details

#inspectObject



19
20
21
22
23
24
25
26
# File 'lib/data_miner/process.rb', line 19

def inspect
  str = "Process(#{resource}) position #{position_in_run}"
  if block
    str << " ran block (#{block_description})"
  else
    str << " called :#{method_name}"
  end
end

#run(run) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/data_miner/process.rb', line 28

def run(run)
  if block
    block.call
  else
    resource.send method_name
  end
  DataMiner.log_info "ran #{inspect}"
end