Class: RgGen::Core::InputBase::InputValueExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/core/input_base/input_value_extractor.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_layers, target_value) ⇒ InputValueExtractor

Returns a new instance of InputValueExtractor.



7
8
9
10
# File 'lib/rggen/core/input_base/input_value_extractor.rb', line 7

def initialize(target_layers, target_value)
  @target_layers = Array(target_layers)
  @target_value = target_value
end

Class Attribute Details

.extractorObject (readonly)

Returns the value of attribute extractor.



13
14
15
# File 'lib/rggen/core/input_base/input_value_extractor.rb', line 13

def extractor
  @extractor
end

Instance Method Details

#extract(input_data) ⇒ Object



27
28
29
30
# File 'lib/rggen/core/input_base/input_value_extractor.rb', line 27

def extract(input_data)
  body = self.class.extractor
  instance_exec(input_data, &body)
end

#target_value?(layer, value) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/rggen/core/input_base/input_value_extractor.rb', line 22

def target_value?(layer, value)
  value == @target_value &&
    (@target_layers.empty? || @target_layers.include?(layer))
end