Class: NotionRubyMapping::Page
- Defined in:
- lib/notion_ruby_mapping/blocks/page.rb
Overview
Notion page object
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#[](key) ⇒ NotionRubyMapping::PropertyCache, Hash
Obtained Page value or PropertyCache.
- #build_child_database(title, *assigns) {|db, db.properties| ... } ⇒ NotionRubyMapping::Database
- #create_child_database(title, *assigns, dry_run: false) {|db, db.properties| ... } ⇒ Object
-
#title ⇒ String
Title.
Methods inherited from Base
#append_block_children, #assert_parent_children_pair, #assign_property, #block?, #children, create_from_json, #created_time, #database?, dry_run_script, #get, #icon, #initialize, #inspect, #json_properties, #last_edited_time, #new_record?, #page?, #properties, #property_values_json, #reload, #restore_from_json, #save, #set_icon, #synced_block_original?, #update_json
Constructor Details
This class inherits a constructor from NotionRubyMapping::Base
Class Method Details
.find(id, dry_run: false) ⇒ NotionRubyMapping::Page, String
11 12 13 14 15 16 17 18 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 11 def self.find(id, dry_run: false) nc = NotionCache.instance if dry_run Base.dry_run_script :get, nc.page_path(id) else nc.page id end end |
Instance Method Details
#[](key) ⇒ NotionRubyMapping::PropertyCache, Hash
Returns obtained Page value or PropertyCache.
22 23 24 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 22 def [](key) get key end |
#build_child_database(title, *assigns) {|db, db.properties| ... } ⇒ NotionRubyMapping::Database
30 31 32 33 34 35 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 30 def build_child_database(title, *assigns) db = Database.new json: {"title" => [TextObject.new(title).property_values_json]}, assign: assigns, parent: {"type" => "page_id", "page_id" => @id} yield db, db.properties if block_given? db end |
#create_child_database(title, *assigns, dry_run: false) {|db, db.properties| ... } ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 37 def create_child_database(title, *assigns, dry_run: false) build_child_database title, *assigns db = Database.new json: {"title" => [TextObject.new(title).property_values_json]}, assign: assigns, parent: {"type" => "page_id", "page_id" => @id} yield db, db.properties db.save dry_run: dry_run end |
#title ⇒ String
Returns title.
47 48 49 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 47 def title properties.select { |p| p.is_a? TitleProperty }.map(&:full_text).join "" end |