Class: NotionRubyMapping::CalloutBlock
- Defined in:
- lib/notion_ruby_mapping/blocks/callout_block.rb
Overview
Notion block
Instance Attribute Summary collapse
- #color ⇒ Object
- #rich_text_array ⇒ Object readonly
Attributes inherited from Block
#can_append, #can_have_children, #caption, #language, #url
Attributes inherited from Base
#archived, #has_children, #id, #json
Instance Method Summary collapse
-
#block_json(not_update: true) ⇒ Hash{String (frozen)->Hash
].
- #emoji ⇒ String?
- #emoji=(emoji) ⇒ Object
- #file_url ⇒ String
- #file_url=(url) ⇒ Object
-
#initialize(text_info = nil, emoji: nil, file_url: nil, sub_blocks: nil, color: "default", json: nil, id: nil, parent: nil) ⇒ CalloutBlock
constructor
A new instance of CalloutBlock.
- #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, #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(text_info = nil, emoji: nil, file_url: nil, sub_blocks: nil, color: "default", json: nil, id: nil, parent: nil) ⇒ CalloutBlock
Returns a new instance of CalloutBlock.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 11 def initialize(text_info = nil, emoji: nil, file_url: nil, sub_blocks: nil, color: "default", json: nil, id: nil, parent: nil) super(json: json, id: id, parent: parent) if @json decode_block_rich_text_array decode_color else rich_text_array_and_color "rich_text", text_info, color @emoji = EmojiObject.emoji_object emoji if emoji @file_object = FileObject.file_object file_url if file_url add_sub_blocks sub_blocks end @can_have_children = true end |
Instance Attribute Details
#color ⇒ Object
28 29 30 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 28 def color @color end |
#rich_text_array ⇒ Object (readonly)
28 29 30 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 28 def rich_text_array @rich_text_array end |
Instance Method Details
#block_json(not_update: true) ⇒ Hash{String (frozen)->Hash
Returns ].
32 33 34 35 36 37 38 39 40 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 32 def block_json(not_update: true) ans = super ans[type] = @rich_text_array.update_property_schema_json not_update ans[type]["color"] = @color ans[type]["icon"] = @emoji.property_values_json if @emoji ans[type]["icon"] = @file_object.property_values_json if @file_object ans[type]["children"] = @sub_blocks.map(&:block_json) if @sub_blocks ans end |
#emoji ⇒ String?
51 52 53 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 51 def emoji @emoji&.emoji end |
#emoji=(emoji) ⇒ Object
57 58 59 60 61 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 57 def emoji=(emoji) @emoji = EmojiObject.emoji_object emoji @file_object = nil @payload.add_update_block_key "icon" end |
#file_url ⇒ String
65 66 67 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 65 def file_url @file_object&.url end |
#file_url=(url) ⇒ Object
71 72 73 74 75 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 71 def file_url=(url) @file_object = FileObject.file_object url @emoji = nil @payload.add_update_block_key "icon" end |
#type ⇒ String
78 79 80 |
# File 'lib/notion_ruby_mapping/blocks/callout_block.rb', line 78 def type "callout" end |