Class: Mindee::V1::Parsing::Common::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/v1/parsing/common/page.rb

Overview

Abstract wrapper class for prediction Pages Holds prediction for a page as well as it’s orientation and id.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_prediction) ⇒ Page

Returns a new instance of Page.

Parameters:

  • raw_prediction (Hash)


28
29
30
31
32
33
34
# File 'lib/mindee/v1/parsing/common/page.rb', line 28

def initialize(raw_prediction)
  @page_id = raw_prediction['id']
  @orientation = Mindee::V1::Parsing::Common::Orientation.new(raw_prediction['orientation'], @page_id)
  return if raw_prediction['extras'].nil?

  @extras = Mindee::V1::Parsing::Common::Extras::Extras.new(raw_prediction['extras'])
end

Instance Attribute Details

#extrasMindee::V1::Parsing::Common::Extras::Extras (readonly)

Additional page-level information.



25
26
27
# File 'lib/mindee/v1/parsing/common/page.rb', line 25

def extras
  @extras
end

#orientationMindee::V1::Parsing::Common::Orientation (readonly)

Orientation of the page.



19
20
21
# File 'lib/mindee/v1/parsing/common/page.rb', line 19

def orientation
  @orientation
end

#page_idInteger (readonly)

ID of the page (as given by the API).

Returns:

  • (Integer)


16
17
18
# File 'lib/mindee/v1/parsing/common/page.rb', line 16

def page_id
  @page_id
end

#predictionMindee::V1::Parsing::Common::Prediction (readonly)

Page prediction



22
23
24
# File 'lib/mindee/v1/parsing/common/page.rb', line 22

def prediction
  @prediction
end

Instance Method Details

#to_sString

Returns:

  • (String)


37
38
39
40
41
42
43
44
# File 'lib/mindee/v1/parsing/common/page.rb', line 37

def to_s
  out_str = String.new
  title = "Page #{@page_id}"
  out_str << "#{title}\n"
  out_str << ('-' * title.size)
  out_str << @prediction.to_s
  out_str
end