<aside> 👉 Links (Property base class)

ButtonProperty

CheckboxProperty

CreatedByProperty

CreatedTimeProperty

DateProperty

EmailProperty

FilesProperty

FormulaProperty

MultiSelectProperty

LastEditedByProperty

LastEditedTimeProperty

NumberProperty

PeopleProperty

PhoneNumberProperty

Property

RelationProperty

RichTextProperty

RollupProperty

SelectProperty

StatusProperty

TitleProperty

UniqueIdProperty

UrlProperty

VerificationProperty

Notion Ruby Mapping Public API Reference

</aside>

<aside> 💡

[P] means methods for Page Property, [DB/DS] means methods for Database or DataSource Property.

</aside>

1. Instance methods

[P] self[num] → RichTextObject

self[num] delegates to included @text_object[num].

  1. self[num] of Page property returns a RichTextObject corresponded to num

  2. 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
    

[P] self << to → RichTextObject

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 { |item| ...} → self

[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"]

Filter usage

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.

[P/DB/DS] filter_contains(value) → Query

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"}}