HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📌
hkob's Notion
/
NotionRubyMapping idea note
NotionRubyMapping idea note
/
Notion Ruby Mapping Public API Reference
Notion Ruby Mapping Public API Reference
/
🎛️
RichTextArray
🎛️

RichTextArray

👉
Links (Controller base class)
🎛️
DiscussionThread
🎛️
NotionCache
🎛️
PropertyCache
🎛️
Query
🎛️
RichTextArray
Notion Ruby Mapping Public API Reference
Notion Ruby Mapping Public API Reference
ℹ️
↑ Table of Contents
1. Singleton methodsrich_text_array(key, text_info = [])2. Instance methods<<(value) → RichTextObjectself[pos] → RichTextObjectdelete_at(pos) → RichTextObjecteach { |item| ... } → self each → Enumeratorfull_textrich_text_objects=(text_info)
Some properties and Database title have an array of RichTextObject. RichTextArray is the delegate class for the array of RichTextObject. Moreover, some methods of TitleProperty, RichTextProperty and Database.title delegate to the included RichTextArray.

1. Singleton methods

rich_text_array(key, text_info = [])

  • [PARAM] key keyword for JSON
  • [PARAM(optional)] text_info
    • 📃
      The following objects are used for this argument.
      • a String like as “text” (String)
      • an Array of Strings (Array of Strings)
      • a RichTextObject (RichTextObject)
      • an Array of RichTextObjects (Array of RichTextObjects)
      • a RichTextArray (RichTextArray)
RichTextArray can be created by a String, some Strings, a RichTextObject and some RichTextObjects. RichTextArray has Array of RichTextObjects. String values will convert to simple TextObjects. If string_contes is already RichTextArray, this method returns the given the RichTextArray.
nullString = RichTextArray.rich_text_array "title" aString = RichTextArray.rich_text_array "title", "A string" twoStrings = RichTextArray.rich_text_array "title", %W[ABC\\n DEF] aTextObject = RichTextArray.rich_text_array "title", TextObject.new("A TextObject") textMentionObjects = RichTextArray.rich_text_array "title", [TextObject.new("A TextObject"), MentionObject.new(user_id: "ABC")] richTextArray = RichTextArray.rich_text_array "title", textMentionObjects # richTextArray == textMentionObjects
ℹ️
↑ Table of Contents

2. Instance methods

<<(value) → RichTextObject

  • [PARAM] value
    • a String like as “text” (String)
    • a RichTextObject (RichTextObject)
<< appends a text or RichTextObject. String value will convert to simple TextObject.
db.database_title << "title" db.database_title << MentionObject.new(user_id: "AAA")
ℹ️
↑ Table of Contents

self[pos] → RichTextObject

  • [PARAM] pos index
self[pos] returns a RichTextObject.
ℹ️
↑ Table of Contents

delete_at(pos) → RichTextObject

  • [PARAM] pos
    • index of object that you want to delete
delete_at obtain the object specified by the index and delete from the array.
db.database_title.delete_at 0 # => #<NotionRubyMapping::TextObject:...>
ℹ️
↑ Table of Contents

each { |item| ... } → self each → Enumerator

RichTextArray is an Enumerable object, so usually combines with .each method.
db.database_title.each do |rto| # exec some methods for a RichTextObject end
ℹ️
↑ Table of Contents

full_text

full_text generates a joined plain text.
db.database_title.full_text => "New database title(Added)"
ℹ️
↑ Table of Contents

rich_text_objects=(text_info)

  • [PARAM(optional)] text_info
    • 📃
      The following objects are used for this argument.
      • a String like as “text” (String)
      • an Array of Strings (Array of Strings)
      • a RichTextObject (RichTextObject)
      • an Array of RichTextObjects (Array of RichTextObjects)
      • a RichTextArray (RichTextArray)
Rich text objects in RichTextArray can be replaced by a String, some Strings, a RichTextObject and some RichTextObjects. RichTextArray has Array of RichTextObjects. String values will convert to simple TextObjects. If string_contents is already RichTextArray, the rich text objects are copyed from the given RichTextArray.
rta = RichTextArray "title" rta.rich_text_objects = "A string"; rta.full_text # => "ABC" rta.rich_text_objects = %W[ABC\\n DEF]; rta.full_text # => "ABC\\nDEF" rta.rich_text_objects = TextObject.new("A TextObject"); rta.full_text # => "A TextObject" rta.rich_text_objects = [TextObject.new("A TextObject"), MentionObject.new(user_id: "ABC")]; rta.full_text # => "A TextObject" rta.rich_text_objects = RichTextArray.rich_text_array("title", "ABC"); rta.full_text # => "ABC"