6.45. kink/doc/model/BLOCK

6.45.1. type block

`block` is a block in a kinkdoc document.

A `block` has following properties:

• Type: a `block_type` which corresponds to "type" property in JSON data

• Text: a `str` which corresponds to "text" property in JSON data

6.45.1.1. Block.type

`type` method returns `Type` property of `Block`.

6.45.1.2. Block.text

`text` returns `Text` property of `Block`.

6.45.1.3. Block.to_json_val

`to_json_val` converts `Block` to a JSON value.

Example

:BLOCK.require_from('kink/doc/model/')
:BLOCK_TYPE.require_from('kink/doc/model/')

:Para <- BLOCK.new(BLOCK_TYPE.paragraph 'hey!')
stdout.print_line(Para.to_json_val.repr)
# => Flat_map("text" "hey!"; "type" "paragraph")

:Code <- BLOCK.new(BLOCK_TYPE.code "1 + 2\n")
stdout.print_line(Code.to_json_val.repr)
# => Flat_map("text" "1 + 2\n"; "type" "code")

6.45.1.4. X == Y

Two `block` values are equal when they have equal `Type` properties and `Text` properties.

Precondition

`Y` must be a `block`.

6.45.2. BLOCK.new(Type Text)

`new` returns a new `block` value with properties `Type` and `Text`.

Preconditions

`Type` must be a `block_type`.

`Text` must be a `str`.

`Type.valid_text?(Text)` must be true.

6.45.3. BLOCK.is?(Val)

`is?` returns whether `Val` is a `block`.