Class: AmazonTRP::FieldValue

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, children, blockMap) ⇒ FieldValue

Returns a new instance of FieldValue.



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/amazon-textract-parser-ruby.rb', line 190

def initialize(block, children, blockMap)
  @block = block
  @confidence = block[:confidence]
  @geometry = Geometry.new(block[:geometry])
  @id = block[:id]
  @text = ""
  @content = []
  
  t = []
  children.each do |eid|
    wb = blockMap[eid]
    if wb[:block_type] == "WORD"
      w = Word.new(wb, blockMap)
      @content.append(w)
      t.append(w.text)
    elsif wb[:block_type] == "SELECTION_ELEMENT"
      se = SelectionElement.new(wb, blockMap)
      @content.append(se)
      t.append(se.selectionStatus)
    end
  end
  
  @text = t.join(' ') if t
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



188
189
190
# File 'lib/amazon-textract-parser-ruby.rb', line 188

def block
  @block
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



183
184
185
# File 'lib/amazon-textract-parser-ruby.rb', line 183

def confidence
  @confidence
end

#contentObject (readonly)

Returns the value of attribute content.



186
187
188
# File 'lib/amazon-textract-parser-ruby.rb', line 186

def content
  @content
end

#geometryObject (readonly)

Returns the value of attribute geometry.



184
185
186
# File 'lib/amazon-textract-parser-ruby.rb', line 184

def geometry
  @geometry
end

#idObject (readonly)

Returns the value of attribute id.



185
186
187
# File 'lib/amazon-textract-parser-ruby.rb', line 185

def id
  @id
end

#textObject (readonly)

Returns the value of attribute text.



187
188
189
# File 'lib/amazon-textract-parser-ruby.rb', line 187

def text
  @text
end

Instance Method Details

#to_sObject



215
216
217
# File 'lib/amazon-textract-parser-ruby.rb', line 215

def to_s
  @text
end