<aside> 👉 Links (Property base class)
Notion Ruby Mapping Public API Reference
</aside>
<aside> 💡
[P] means methods for Page Property, [DB/DS] means methods for Database or DataSource Property.
</aside>
self[num] delegates to included @text_object[num].
self[num] of Page property returns a RichTextObject corresponded to num
self[num] of Database property returns nil, because @text_object of the property is {}.
page.properties["TextTitle"][0]
# => #<NotionRubyMapping::TextObject:...>
db.properties["TextTitle"][0]
# => nil
self << to delegates to included @text_object << to. If the argument is a String, it is converted to RichTextObject and append to @text_object. This method returns generated or given RichTextObject.
prtp = page.properties["TextTitle"]
prtp << "Added text"
=> #<NotionRubyMapping::TextObject:0x000000010fc60d80 @options={"plain_text"=>"Added text"}, @text="Added text", @type="text", @will_update=false>
prtp.full_text
=> "new textAdded text"
prtp << MentionObject.new("template_mention" => "now")
=> => #<NotionRubyMapping::MentionObject:0x00000001100d2620 @options={"template_mention"=>"now"}, @type="mention">
[P] self.each → Enumerator
self.each delegates to included @text_object.each. Since RichTextProperty includes Enumerable, other Enumerable methods can be used.
prtp = page.properties["TextTitle"]
prtp.count
# => 1
prtp.map(&:text)
# => ["new text"]
These methods return a Query; .filter in the examples reads its generated Hash. Creating a condition does not send an API request or update the property value.
For ordinary rich_text filters, omit condition: and another_type:. The shared methods accept these keywords for nested Formula / Rollup conditions; they are not needed for the examples below. The filter methods do not validate or normalize the supplied string.
Creates a Query object whose rich_text condition matches a value that contains the given string. The value argument is a String and is passed to the filter unchanged.
ds.properties["TextTitle"].filter_contains("Notion").filter
# => {"property" => "TextTitle", "rich_text" => {"contains" => "Notion"}}