Class: Maglev::ExtractedDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/maglev/extracted_document.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_identifier:, text:, metadata:, status:) ⇒ ExtractedDocument

Returns a new instance of ExtractedDocument.



20
21
22
23
24
25
26
# File 'lib/maglev/extracted_document.rb', line 20

def initialize(source_identifier:, text:, metadata:, status:)
  @source_identifier = source_identifier
  @text = text
  @metadata = .freeze
  @status = status
  freeze
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



5
6
7
# File 'lib/maglev/extracted_document.rb', line 5

def 
  @metadata
end

#source_identifierObject (readonly)

Returns the value of attribute source_identifier.



5
6
7
# File 'lib/maglev/extracted_document.rb', line 5

def source_identifier
  @source_identifier
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/maglev/extracted_document.rb', line 5

def status
  @status
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/maglev/extracted_document.rb', line 5

def text
  @text
end

Class Method Details

.extracted(source_identifier:, text:, metadata: {}) ⇒ Object



7
8
9
# File 'lib/maglev/extracted_document.rb', line 7

def self.extracted(source_identifier:, text:, metadata: {})
  new(source_identifier: source_identifier, text: text, metadata: , status: :extracted)
end

.skipped(source_identifier:, reason:, metadata: {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/maglev/extracted_document.rb', line 11

def self.skipped(source_identifier:, reason:, metadata: {})
  new(
    source_identifier: source_identifier,
    text: "",
    metadata: .merge(reason: reason),
    status: :skipped
  )
end

Instance Method Details

#extracted?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/maglev/extracted_document.rb', line 28

def extracted?
  status == :extracted
end

#skipped?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/maglev/extracted_document.rb', line 32

def skipped?
  status == :skipped
end