Class: NotionToHtml::BasePage

Inherits:
Object
  • Object
show all
Includes:
Renderers
Defined in:
lib/notion_to_html/base_page.rb

Constant Summary

Constants included from Renderers

Renderers::DEFAULT_CSS_CLASSES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Renderers

#annotation_to_css_class, #render_bulleted_list_item, #render_callout, #render_code, #render_date, #render_heading_1, #render_heading_2, #render_heading_3, #render_image, #render_numbered_list_item, #render_paragraph, #render_quote, #render_table_of_contents, #render_video, #text_renderer

Constructor Details

#initialize(data) ⇒ BasePage

Initializes a new BasePage object.

Parameters:

  • data (Hash)

    The raw data of the page from the Notion API.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/notion_to_html/base_page.rb', line 47

def initialize(data)
  @id = data['id']
  @created_time = data['created_time']
  @last_edited_time = data['last_edited_time']
  @created_by = data['created_by'] # TODO: handle user object
  @last_edited_by = data['last_edited_by'] # TODO: handle user object
  @cover = data['cover'] # TODO: handle external type
  @icon = data['icon'] # TODO: handle emoji type
  @parent = data['parent'] # TODO: handle database_id type
  @archived = data['archived']
  @properties = data['properties'] # TODO: handle properties object
  process_properties
  @url = data['url']
end

Instance Attribute Details

#archivedBoolean (readonly)

Returns whether the page is archived.

Returns:

  • (Boolean)

    whether the page is archived.



29
30
31
# File 'lib/notion_to_html/base_page.rb', line 29

def archived
  @archived
end

#coverHash? (readonly)

Returns the cover image of the page.

Returns:

  • (Hash, nil)

    the cover image of the page.



23
24
25
# File 'lib/notion_to_html/base_page.rb', line 23

def cover
  @cover
end

#created_byString (readonly)

Returns the user who created the page.

Returns:

  • (String)

    the user who created the page.



19
20
21
# File 'lib/notion_to_html/base_page.rb', line 19

def created_by
  @created_by
end

#created_timeString (readonly)

Returns the creation timestamp of the page.

Returns:

  • (String)

    the creation timestamp of the page.



15
16
17
# File 'lib/notion_to_html/base_page.rb', line 15

def created_time
  @created_time
end

#descriptionArray<Hash>? (readonly)

Returns the description of the page.

Returns:

  • (Array<Hash>, nil)

    the description of the page.



41
42
43
# File 'lib/notion_to_html/base_page.rb', line 41

def description
  @description
end

#iconHash? (readonly)

Returns the icon of the page.

Returns:

  • (Hash, nil)

    the icon of the page.



25
26
27
# File 'lib/notion_to_html/base_page.rb', line 25

def icon
  @icon
end

#idString (readonly)

Returns the ID of the page.

Returns:

  • (String)

    the ID of the page.



13
14
15
# File 'lib/notion_to_html/base_page.rb', line 13

def id
  @id
end

#last_edited_byString (readonly)

Returns the user who last edited the page.

Returns:

  • (String)

    the user who last edited the page.



21
22
23
# File 'lib/notion_to_html/base_page.rb', line 21

def last_edited_by
  @last_edited_by
end

#last_edited_timeString (readonly)

Returns the last edited timestamp of the page.

Returns:

  • (String)

    the last edited timestamp of the page.



17
18
19
# File 'lib/notion_to_html/base_page.rb', line 17

def last_edited_time
  @last_edited_time
end

#parentHash (readonly)

Returns the parent of the page (e.g., database ID).

Returns:

  • (Hash)

    the parent of the page (e.g., database ID).



27
28
29
# File 'lib/notion_to_html/base_page.rb', line 27

def parent
  @parent
end

#propertiesHash (readonly)

Returns the properties of the page.

Returns:

  • (Hash)

    the properties of the page.



31
32
33
# File 'lib/notion_to_html/base_page.rb', line 31

def properties
  @properties
end

#published_atString? (readonly)

Returns the publication date of the page.

Returns:

  • (String, nil)

    the publication date of the page.



33
34
35
# File 'lib/notion_to_html/base_page.rb', line 33

def published_at
  @published_at
end

#slugString? (readonly)

Returns the slug of the page.

Returns:

  • (String, nil)

    the slug of the page.



39
40
41
# File 'lib/notion_to_html/base_page.rb', line 39

def slug
  @slug
end

#tagsArray<Hash>? (readonly)

Returns the tags associated with the page.

Returns:

  • (Array<Hash>, nil)

    the tags associated with the page.



35
36
37
# File 'lib/notion_to_html/base_page.rb', line 35

def tags
  @tags
end

#titleArray<Hash>? (readonly)

Returns the title of the page.

Returns:

  • (Array<Hash>, nil)

    the title of the page.



37
38
39
# File 'lib/notion_to_html/base_page.rb', line 37

def title
  @title
end

#urlString (readonly)

Returns the URL of the page.

Returns:

  • (String)

    the URL of the page.



43
44
45
# File 'lib/notion_to_html/base_page.rb', line 43

def url
  @url
end

Instance Method Details

#formatted_description(options = {}) ⇒ String

Renders the formatted description of the page.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options for rendering the description.

Returns:

  • (String)

    The formatted description.



72
73
74
# File 'lib/notion_to_html/base_page.rb', line 72

def formatted_description(options = {})
  render_paragraph(@description, options)
end

#formatted_published_at(options = {}) ⇒ String

Renders the formatted publication date of the page.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options for rendering the publication date.

Returns:

  • (String)

    The formatted publication date.



79
80
81
# File 'lib/notion_to_html/base_page.rb', line 79

def formatted_published_at(options = {})
  render_date(@published_at, options)
end

#formatted_title(options = {}) ⇒ String

Renders the formatted title of the page.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options for rendering the title.

Returns:

  • (String)

    The formatted title.



65
66
67
# File 'lib/notion_to_html/base_page.rb', line 65

def formatted_title(options = {})
  render_heading_1(@title, options)
end