Class: NotionOrbit::NotionObjects::Blocks

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/notion_orbit/notion_objects/blocks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_blocks, notion_api_key, indentation: 0) ⇒ Blocks

Returns a new instance of Blocks.



8
9
10
11
12
# File 'lib/notion_orbit/notion_objects/blocks.rb', line 8

def initialize(raw_blocks, notion_api_key, indentation: 0)
  @blocks = raw_blocks.map{ |raw_block| Block.new_from_raw_block(raw_block, notion_api_key, indentation: indentation) }
  @notion_api_key = notion_api_key
  @indentation = indentation
end

Instance Attribute Details

#blocksObject

Returns the value of attribute blocks.



6
7
8
# File 'lib/notion_orbit/notion_objects/blocks.rb', line 6

def blocks
  @blocks
end

Instance Method Details

#to_markdownObject



14
15
16
# File 'lib/notion_orbit/notion_objects/blocks.rb', line 14

def to_markdown
  @blocks.map { |block| " " * @indentation + block.to_markdown }.join("\n").rstrip.gsub("\n","\\n")
end