Class: AmazonTRP::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon-textract-parser-ruby.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, blockMap) ⇒ Field

Returns a new instance of Field.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/amazon-textract-parser-ruby.rb', line 225

def initialize(block, blockMap)
  @key = nil
  @value = nil
  
  block[:relationships].each do |item|
    if item[:type] == "CHILD"
      @key = FieldKey.new(block, item[:ids], blockMap)
    elsif item[:type] == "VALUE"
      item[:ids].each do |eid|
        vkvs = blockMap[eid]
        if vkvs[:entity_types].include?('VALUE')
          if vkvs.has_key?(:relationships)
            vkvs[:relationships].each do |vitem|
              @value = FieldValue.new(vkvs, vitem[:ids], blockMap) if vitem[:type] == "CHILD"
            end
          end
        end
      end
    end
  end
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



222
223
224
# File 'lib/amazon-textract-parser-ruby.rb', line 222

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



223
224
225
# File 'lib/amazon-textract-parser-ruby.rb', line 223

def value
  @value
end

Instance Method Details

#to_sObject



247
248
249
250
251
252
253
254
255
# File 'lib/amazon-textract-parser-ruby.rb', line 247

def to_s
  k = ""
  v = ""
  
  k = @key.to_s if @key
  v = @value.to_s if @value
  
  return "Field: #{k} = #{v}"
end