Class: LoaderRuby::Document
- Inherits:
-
Object
- Object
- LoaderRuby::Document
- Defined in:
- lib/loader_ruby/document.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #format ⇒ Object
-
#initialize(content:, metadata: {}) ⇒ Document
constructor
A new instance of Document.
- #pages ⇒ Object
- #size ⇒ Object
- #source ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(content:, metadata: {}) ⇒ Document
Returns a new instance of Document.
7 8 9 10 |
# File 'lib/loader_ruby/document.rb', line 7 def initialize(content:, metadata: {}) @content = content = end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/loader_ruby/document.rb', line 5 def content @content end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/loader_ruby/document.rb', line 5 def end |
Instance Method Details
#empty? ⇒ Boolean
28 29 30 |
# File 'lib/loader_ruby/document.rb', line 28 def empty? @content.nil? || @content.strip.empty? end |
#format ⇒ Object
16 17 18 |
# File 'lib/loader_ruby/document.rb', line 16 def format [:format] end |
#pages ⇒ Object
20 21 22 |
# File 'lib/loader_ruby/document.rb', line 20 def pages [:pages] end |
#size ⇒ Object
24 25 26 |
# File 'lib/loader_ruby/document.rb', line 24 def size @content.length end |
#source ⇒ Object
12 13 14 |
# File 'lib/loader_ruby/document.rb', line 12 def source [:source] end |
#to_h ⇒ Object
32 33 34 35 36 37 |
# File 'lib/loader_ruby/document.rb', line 32 def to_h { content: @content, metadata: } end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/loader_ruby/document.rb', line 39 def to_s "Document(source: #{source}, format: #{self.format}, size: #{size})" end |