UrlProperty(Page): NotionRubyMapping 解説 (52)

はじめに

NotionRubyMapping 解説の第52回目です。ページ側のプロパティを解説しています。今回は UrlProperty の変更です。現在はデータベース内の最初のページを使って説明していきます。

New title

irb(main):002> page = Page.find "https://www.notion.so/hkob/619a113814134c759773175ac988b96a?pvs=4"
=> NotionRubyMapping::Page-619a113814134c759773175ac988b96a

UrlProperty

まず、UrlProperty を取得します。

irb(main):003> up = page.properties["Url"]
=>
#<NotionRubyMapping::UrlProperty:0x000000011e678030

url で設定されている URL が取得できます。初期状態では空なので url は nil になっています。

irb(main):004> up.url
=> nil

url = で url を更新できます。

irb(main):005> up.url = "https://hkob.notion.site"
=> "https://hkob.notion.site"
irb(main):006> page.save
=> NotionRubyMapping::Page-619a113814134c759773175ac988b96a

設定された URL がプロパティに設定されていることがわかります。

UrlProperty

おわりに

今回はページの UrlProperty の変更を説明しました。これは単に URL が設定できるだけの簡単なプロパティです。

UrlProperty のマニュアルはこちらです。

UrlProperty

NotionRubyMapping解説