Class: NotionRubyMapping::CommentObject

Inherits:
Object
  • Object
show all
Defined in:
lib/notion_ruby_mapping/objects/comment_object.rb

Overview

CommentObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text_objects: nil, json: {}) ⇒ CommentObject

Returns a new instance of CommentObject.

Parameters:

  • text_objects (String) (defaults to: nil)


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/notion_ruby_mapping/objects/comment_object.rb', line 7

def initialize(text_objects: nil, json: {})
  if text_objects
    @text_objects = RichTextArray.new "rich_text", text_objects: text_objects
    @json = {}
  elsif json
    @json = json
    @text_objects = RichTextArray.new "rich_text", json: json["rich_text"]
  else
    raise StandardError, "Either text_objects or json is required CommentObject"
  end
  @will_update = false
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



19
20
21
# File 'lib/notion_ruby_mapping/objects/comment_object.rb', line 19

def json
  @json
end

#text_objectsObject (readonly)

Returns the value of attribute text_objects.



19
20
21
# File 'lib/notion_ruby_mapping/objects/comment_object.rb', line 19

def text_objects
  @text_objects
end

#will_updateObject (readonly)

Returns the value of attribute will_update.



19
20
21
# File 'lib/notion_ruby_mapping/objects/comment_object.rb', line 19

def will_update
  @will_update
end

Instance Method Details

#discussion_idObject



21
22
23
# File 'lib/notion_ruby_mapping/objects/comment_object.rb', line 21

def discussion_id
  NotionCache.instance.hex_id @json["discussion_id"]
end

#full_textString

Returns full_text.

Returns:

  • (String)

    full_text



26
27
28
# File 'lib/notion_ruby_mapping/objects/comment_object.rb', line 26

def full_text
  @text_objects.full_text
end