Class: TextExtractor::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/text_extractor/value.rb

Direct Known Subclasses

InlineValue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, re, &block) ⇒ Value

Returns a new instance of Value.



5
6
7
8
9
# File 'lib/text_extractor/value.rb', line 5

def initialize(id, re, &block)
  @id = id
  @re = re
  @block = block
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/text_extractor/value.rb', line 3

def id
  @id
end

#reObject (readonly)

Returns the value of attribute re.



3
4
5
# File 'lib/text_extractor/value.rb', line 3

def re
  @re
end

Instance Method Details

#convert(value) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/text_extractor/value.rb', line 11

def convert(value)
  @block ? @block.call(value) : value
rescue StandardError => e
  raise e.class,
        'in custom conversion of '\
        "value(#{id.inspect}, #{re.inspect}): #{e.message}"
end