Class: Chatpdf::Session::Answer
- Inherits:
-
Object
- Object
- Chatpdf::Session::Answer
- Defined in:
- lib/chatpdf/session/answer.rb
Constant Summary collapse
- PAGE_NUMBER_KEY =
"pageNumber".freeze
- @@_id =
0
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(response = {}) ⇒ Answer
constructor
A new instance of Answer.
- #references ⇒ Object
- #serialise ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response = {}) ⇒ Answer
Returns a new instance of Answer.
9 10 11 12 13 14 |
# File 'lib/chatpdf/session/answer.rb', line 9 def initialize(response = {}) @content = response["content"] @references = response["references"] @@_id = Random.uuid @id = @@_id end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/chatpdf/session/answer.rb', line 7 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/chatpdf/session/answer.rb', line 7 def id @id end |
Instance Method Details
#references ⇒ Object
20 21 22 23 24 |
# File 'lib/chatpdf/session/answer.rb', line 20 def references return [] if @references.nil? @references.map { |reference| reference[PAGE_NUMBER_KEY] } end |
#serialise ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/chatpdf/session/answer.rb', line 26 def serialise { id: id, content: content, references: references } end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/chatpdf/session/answer.rb', line 16 def to_s @content end |