Class: NotionRubyMapping::ColumnBlock
- Defined in:
- lib/notion_ruby_mapping/blocks/column_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) ⇒ Hash{String (frozen)->Hash
].
-
#initialize(sub_blocks = [], json: nil, id: nil, parent: nil, width_ratio: nil) ⇒ ColumnBlock
constructor
A new instance of ColumnBlock.
- #type ⇒ String
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, #data_source?, data_source_id, #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(sub_blocks = [], json: nil, id: nil, parent: nil, width_ratio: nil) ⇒ ColumnBlock
Returns a new instance of ColumnBlock.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/notion_ruby_mapping/blocks/column_block.rb', line 8 def initialize(sub_blocks = [], json: nil, id: nil, parent: nil, width_ratio: nil) super(json: json, id: id, parent: parent) add_sub_blocks sub_blocks unless json @can_have_children = true @can_append = false @width_ratio = if !width_ratio.nil? width_ratio elsif json && json["column"] && json["column"]["width_ratio"] json["column"]["width_ratio"] end end |
Instance Method Details
#block_json(not_update: true) ⇒ Hash{String (frozen)->Hash
Returns ].
27 28 29 30 31 32 |
# File 'lib/notion_ruby_mapping/blocks/column_block.rb', line 27 def block_json(not_update: true) ans = super ans[type] = @width_ratio ? {"width_ratio" => @width_ratio} : {} ans[type]["children"] = @sub_blocks.map(&:block_json) if @sub_blocks ans end |
#type ⇒ String
21 22 23 |
# File 'lib/notion_ruby_mapping/blocks/column_block.rb', line 21 def type "column" end |