Class: Google::Cloud::Vision::Annotation::Text::Page
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation::Text::Page
- Defined in:
- lib/google/cloud/vision/annotation/text.rb
Overview
Page
A page within a detected text (OCR). See #pages.
Defined Under Namespace
Classes: Block, Language, Paragraph, Symbol, Word
Instance Method Summary collapse
-
#blocks ⇒ Array<Block>
List of blocks of text, images etc on this page.
-
#break_type ⇒ ::Symbol
The type of a detected break at the start or end of the page.
-
#height ⇒ Integer
Page height in pixels.
-
#languages ⇒ Array<Language>
A list of detected languages together with confidence.
-
#prefix_break? ⇒ Boolean
True if a detected break prepends the page.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
-
#width ⇒ Integer
Page width in pixels.
Instance Method Details
#blocks ⇒ Array<Block>
List of blocks of text, images etc on this page.
344 345 346 347 348 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 344 def blocks @blocks ||= Array(@grpc.blocks).map do |b| Block.from_grpc b end end |
#break_type ⇒ ::Symbol
The type of a detected break at the start or end of the page.
304 305 306 307 308 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 304 def break_type return nil if @grpc.property.nil? @grpc.property.detected_break && @grpc.property.detected_break.type.to_sym end |
#height ⇒ Integer
Page height in pixels.
335 336 337 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 335 def height @grpc.height end |
#languages ⇒ Array<Language>
A list of detected languages together with confidence.
292 293 294 295 296 297 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 292 def languages return [] if @grpc.property.nil? @languages ||= Array(@grpc.property.detected_languages).map do |l| Language.from_grpc l end end |
#prefix_break? ⇒ Boolean
True if a detected break prepends the page.
315 316 317 318 319 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 315 def prefix_break? return nil if @grpc.property.nil? @grpc.property.detected_break && @grpc.property.detected_break.is_prefix end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
355 356 357 358 359 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 355 def to_h { languages: languages.map(&:to_h), break_type: break_type, prefix_break: prefix_break?, width: width, height: height, blocks: blocks.map(&:to_h) } end |
#width ⇒ Integer
Page width in pixels.
326 327 328 |
# File 'lib/google/cloud/vision/annotation/text.rb', line 326 def width @grpc.width end |