Class: Blockhead::ValueExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/blockhead/value_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, *args, &block) ⇒ ValueExtractor

Returns a new instance of ValueExtractor.



5
6
7
8
9
10
11
12
# File 'lib/blockhead/value_extractor.rb', line 5

def initialize(value, *args, &block)
  proc = block.to_proc if block
  @extractor = Extractors::Enumerable.new value, *args, proc

  extractors.inject(extractor) do |fallback, link|
    fallback.next = link.new value, *args, proc
  end
end

Instance Attribute Details

#extractorObject (readonly)

Returns the value of attribute extractor.



3
4
5
# File 'lib/blockhead/value_extractor.rb', line 3

def extractor
  @extractor
end

Instance Method Details

#extractObject



14
15
16
# File 'lib/blockhead/value_extractor.rb', line 14

def extract
  extractor.extract
end