Class: NotionRb::Utils::Parser

Inherits:
Object
  • Object
show all
Includes:
Types
Defined in:
lib/notion_rb/utils/parser.rb

Constant Summary

Constants included from Types

Types::TYPE_MAPPER

Instance Method Summary collapse

Methods included from Types

#select_parser, #valid_block_type?

Constructor Details

#initialize(value, position) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
12
13
14
15
16
# File 'lib/notion_rb/utils/parser.rb', line 8

def initialize(value, position)
  unless valid_block_type?(value['type'])
    raise ArgumentError, 'Invalid block type'
  end

  @value = value
  @position = position
  @parser = select_parser @value['type']
end

Instance Method Details

#parseObject



18
19
20
# File 'lib/notion_rb/utils/parser.rb', line 18

def parse
  @parser == :null ? null : base
end