Class: NotionRubyMapping::TableBlock
- Defined in:
- lib/notion_ruby_mapping/blocks/table_block.rb
Overview
Notion block
Instance Attribute Summary
Attributes inherited from Block
#can_append, #can_have_children, #caption, #color, #language, #rich_text_array, #url
Attributes inherited from Base
#archived, #has_children, #id, #json
Instance Method Summary collapse
- #block_json(not_update: true) ⇒ Object
-
#initialize(table_width: nil, has_column_header: false, has_row_header: false, table_rows: nil, json: nil, id: nil, parent: nil) ⇒ TableBlock
constructor
A new instance of TableBlock.
- #type ⇒ String (frozen)
Methods inherited from Block
#append_after, #children_block_json, decode_block, #decode_block_caption, #decode_block_rich_text_array, #decode_color, #destroy, find, type2class, #update, #update_block_json
Methods inherited from Base
#append_block_children, #assert_parent_children_pair, #assign_property, #block?, block_id, #children, #comments, #cover, create_from_json, #created_time, #database?, database_id, dry_run_script, #get, #icon, #inspect, #json_properties, #last_edited_time, #new_record?, #page?, page_id, #parent, #parent_id, #properties, #property_values_json, #reload, #restore_from_json, #save, #set_cover, #set_icon, #synced_block_original?, #update_json
Constructor Details
#initialize(table_width: nil, has_column_header: false, has_row_header: false, table_rows: nil, json: nil, id: nil, parent: nil) ⇒ TableBlock
Returns a new instance of TableBlock.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/notion_ruby_mapping/blocks/table_block.rb', line 13 def initialize(table_width: nil, has_column_header: false, has_row_header: false, table_rows: nil, json: nil, id: nil, parent: nil) super json: json, id: id, parent: parent if @json sub_json = @json[type] @has_column_header = sub_json["has_column_header"] @has_row_header = sub_json["has_row_header"] @table_width = sub_json["table_width"] else @table_width = table_width @has_column_header = has_column_header @has_row_header = has_row_header if table_rows @table_rows = table_rows.map do |table_row| TableRowBlock.new table_row, @table_width end end end @can_have_children = true end |
Instance Method Details
#block_json(not_update: true) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/notion_ruby_mapping/blocks/table_block.rb', line 34 def block_json(not_update: true) ans = super ans[type] = { "has_column_header" => @has_column_header, "has_row_header" => @has_row_header, "table_width" => @table_width, } ans[type]["children"] = @table_rows.map(&:block_json) if @table_rows ans end |
#type ⇒ String (frozen)
46 47 48 |
# File 'lib/notion_ruby_mapping/blocks/table_block.rb', line 46 def type "table" end |