Class: AmazonTRP::Line

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) ⇒ Line

Returns a new instance of Line.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/amazon-textract-parser-ruby.rb', line 99

def initialize(block, blockMap)
  @block = block
  @confidence = block[:confidence]
  @geometry = Geometry.new(block[:geometry])
  @id = block[:id]
  
  @text = block[:text] || ""
  
  @words = []
  if block[:relationships]
    block[:relationships].each do |rs|
      if rs[:type] == 'CHILD'
        rs[:ids].each do |cid|
          if blockMap[cid][:block_type] == "WORD"
            @words.append(Word.new(blockMap[cid], blockMap))
          end
        end
      end
    end
  end
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



97
98
99
# File 'lib/amazon-textract-parser-ruby.rb', line 97

def block
  @block
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



92
93
94
# File 'lib/amazon-textract-parser-ruby.rb', line 92

def confidence
  @confidence
end

#geometryObject (readonly)

Returns the value of attribute geometry.



93
94
95
# File 'lib/amazon-textract-parser-ruby.rb', line 93

def geometry
  @geometry
end

#idObject (readonly)

Returns the value of attribute id.



94
95
96
# File 'lib/amazon-textract-parser-ruby.rb', line 94

def id
  @id
end

#textObject (readonly)

Returns the value of attribute text.



96
97
98
# File 'lib/amazon-textract-parser-ruby.rb', line 96

def text
  @text
end

#wordsObject (readonly)

Returns the value of attribute words.



95
96
97
# File 'lib/amazon-textract-parser-ruby.rb', line 95

def words
  @words
end

Instance Method Details

#to_sObject



121
122
123
124
125
126
127
128
129
# File 'lib/amazon-textract-parser-ruby.rb', line 121

def to_s
  s = "Line: "
  s = s + @text + "\n"
  s = s + "Words: "
  @words.each do |word|
    s = s + "[#{word}]"
  end
  return s
end