NumberProperty(Page): NotionRubyMapping 解説 (45)

はじめに

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

無題

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

NumberProperty

まず、NumberProperty を取得します。

=> NotionRubyMapping::Page-619a113814134c759773175ac988b96a
irb(main):003> np = page.properties["Number"]
=>
#<NotionRubyMapping::NumberProperty:0x000000011df51540

number で数値の設定状況を確認できます。前回のテストで入力した 123456789 が入っていました。

irb(main):004> np.number
=> 123456789

number = で数値を代入できます。

irb(main):005> np.number = 3.14159
=> 3.14159
irb(main):006> page.save
=> NotionRubyMapping::Page-619a113814134c759773175ac988b96a

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

NumberProperty

おわりに

今回はページの NumberProperty の変更を説明しました。number で値を設定するだけなので簡単ですね。

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

NumberProperty

NotionRubyMapping解説