Class: Datalab::MarkerResult
- Inherits:
-
Object
- Object
- Datalab::MarkerResult
- Defined in:
- lib/datalab/marker_result.rb
Instance Method Summary collapse
- #complete? ⇒ Boolean
-
#failure_message ⇒ Object
If
success?
returnsfalse
this method will return a message explaining the reason for the failure. - #id ⇒ Object
- #images ⇒ Object
-
#initialize(attributes) ⇒ MarkerResult
constructor
A new instance of MarkerResult.
-
#markdown ⇒ Object
The
markdown
method returns the markdown content extracted from the given document. - #merge(attributes) ⇒ Object
- #metadata ⇒ Object
- #processing? ⇒ Boolean
- #status ⇒ Object
-
#success? ⇒ Boolean
The
success?
method returnstrue
if the converstion was successful.
Constructor Details
#initialize(attributes) ⇒ MarkerResult
Returns a new instance of MarkerResult.
4 5 6 7 8 9 |
# File 'lib/datalab/marker_result.rb', line 4 def initialize( attributes ) @success = attributes[ :success ] || [ :processing, :complete ].include?( attributes[ :status ]&.to_sym ) @attributes = attributes || {} end |
Instance Method Details
#complete? ⇒ Boolean
34 35 36 |
# File 'lib/datalab/marker_result.rb', line 34 def complete? status == :complete end |
#failure_message ⇒ Object
If success?
returns false
this method will return a message explaining the reason for the failure.
42 43 44 |
# File 'lib/datalab/marker_result.rb', line 42 def @attributes[ :error ] end |
#id ⇒ Object
11 12 13 |
# File 'lib/datalab/marker_result.rb', line 11 def id @attributes[ :request_id ] end |
#images ⇒ Object
56 57 58 |
# File 'lib/datalab/marker_result.rb', line 56 def images @attribute[ :images ] end |
#markdown ⇒ Object
The markdown
method returns the markdown content extracted from the given document.
49 50 51 |
# File 'lib/datalab/marker_result.rb', line 49 def markdown @attributes[ :markdown ] end |
#merge(attributes) ⇒ Object
70 71 72 |
# File 'lib/datalab/marker_result.rb', line 70 def merge( attributes ) self.class.new( ( @attributes || {} ).merge( attributes ) ) end |
#metadata ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/datalab/marker_result.rb', line 60 def unless @metadata = @attributes[ :metadata ] || {} @metadata = .transform_keys do | key | key.to_s.gsub( /([a-z])([A-Z])/, '\1_\2' ).downcase end end @metadata end |
#processing? ⇒ Boolean
30 31 32 |
# File 'lib/datalab/marker_result.rb', line 30 def processing? status == :processing end |
#status ⇒ Object
26 27 28 |
# File 'lib/datalab/marker_result.rb', line 26 def status @attributes[ :status ]&.to_sym || :processing end |
#success? ⇒ Boolean
The success?
method returns true
if the converstion was successful.
Note that the response success?
tells you if the call to the Datalab API was successful while this success?
method tells you if the actual conversaion operation began successfully.
22 23 24 |
# File 'lib/datalab/marker_result.rb', line 22 def success? @success || false end |