Class: NotionToMd::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/notion_to_md/converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page_id:, token: nil) ⇒ Converter

Returns a new instance of Converter.



7
8
9
10
# File 'lib/notion_to_md/converter.rb', line 7

def initialize(page_id:, token: nil)
  @notion = Notion::Client.new(token: token || ENV['NOTION_TOKEN'])
  @page_id = page_id
end

Instance Attribute Details

#page_idObject (readonly)

Returns the value of attribute page_id.



5
6
7
# File 'lib/notion_to_md/converter.rb', line 5

def page_id
  @page_id
end

Instance Method Details

#convert(frontmatter: false) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/notion_to_md/converter.rb', line 12

def convert(frontmatter: false)
  md_page = Page.new(page: page, blocks: page_blocks)
  "    \#{md_page.frontmatter if frontmatter}\n    \#{md_page.body}\n  MD\nend\n"