Class: AmazonTRP::Line
- Inherits:
-
Object
- Object
- AmazonTRP::Line
- Defined in:
- lib/amazon-textract-parser-ruby.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#geometry ⇒ Object
readonly
Returns the value of attribute geometry.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#words ⇒ Object
readonly
Returns the value of attribute words.
Instance Method Summary collapse
-
#initialize(block, blockMap) ⇒ Line
constructor
A new instance of Line.
- #to_s ⇒ Object
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
#block ⇒ Object (readonly)
Returns the value of attribute block.
97 98 99 |
# File 'lib/amazon-textract-parser-ruby.rb', line 97 def block @block end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
92 93 94 |
# File 'lib/amazon-textract-parser-ruby.rb', line 92 def confidence @confidence end |
#geometry ⇒ Object (readonly)
Returns the value of attribute geometry.
93 94 95 |
# File 'lib/amazon-textract-parser-ruby.rb', line 93 def geometry @geometry end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
94 95 96 |
# File 'lib/amazon-textract-parser-ruby.rb', line 94 def id @id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
96 97 98 |
# File 'lib/amazon-textract-parser-ruby.rb', line 96 def text @text end |
#words ⇒ Object (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_s ⇒ Object
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 |