<aside> 👉

Links (Block base class)

Page

AudioBlock

Block

CalloutBlock

DividerBlock

Heading1Block

ImageBlock

ParagraphBlock

TableOfContentsBlock

ToggleHeading2Block

Database

BookmarkBlock

CodeBlock

EmbedBlock

Heading2Block

LinkPreviewBlock

PdfBlock

ToDoBlock

ToggleHeading3Block

DataSource 🆕

BreadcrumbBlock

ColumnBlock

EquationBlock

Heading3Block

LinkToPageBlock

QuoteBlock

ToggleBlock

ToggleHeading4Block

List

BulletedListItemBlock

ColumnListBlock

FileBlock

Heading4Block

NumberedListItemBlock

SyncedBlock

ToggleHeading1Block

VideoBlock

Notion Ruby Mapping Public API Reference

</aside>

1. Class methods

self.new(expression = nil) → EquationBlock

self.new creates an EquationBlock. When an EquationObject is supplied, the block uses that object internally. The equation block payload contains its expression value.

block = EquationBlock.new "x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"
block.block_json
# => {"type"=>"equation", "object"=>"block", "equation"=>{"expression"=>"x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"}}

When the argument is omitted or nil, expression is an empty string.

EquationBlock.new.expression
# => ""

2. Instance methods

expression → String

expression returns the LaTeX expression string of the EquationBlock.

block = EquationBlock.new "x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"
block.expression
# => "x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"

expression=(new_expression)

expression= replaces the equation expression and marks expression for the next block update.

block = EquationBlock.new "x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"
block.expression = "X(z) = \\sum_{n=-\\infty}^{\\infty}x[n]z^{-n}"
block.update_block_json
# => {"equation"=>{"expression"=>"X(z) = \\sum_{n=-\\infty}^{\\infty}x[n]z^{-n}"}}

Ruby interprets backslashes inside double-quoted strings. Escape each backslash as \\, or use an appropriate string literal for the LaTeX expression.

save(dry_run: false) → EquationBlock, String

$\fbox{implemented in Block}$

save sends the pending equation block changes to the Notion API. Without dry_run, it returns the updated EquationBlock created from the API response.

block = Block.find "899e342cec84415f9ff86225704cbb75"
block.expression = "E = mc^2"
block.save
# => #<NotionRubyMapping::EquationBlock:...>

Use dry_run: true to inspect the update request without sending it.

block.expression = "E = mc^2"
block.save dry_run: true
# => "#!/bin/sh\n# curl -X PATCH ..."