Class: NotionToMd::PageProperty
Class Method Summary
collapse
escape_frontmatter_value
Class Method Details
.checkbox(prop) ⇒ Object
68
69
70
71
72
|
# File 'lib/notion_to_md/page_property.rb', line 68
def checkbox(prop)
prop[:checkbox].nil? ? nil : prop[:checkbox].to_s
rescue NoMethodError
nil
end
|
.date(prop) ⇒ Object
date type properties not supported:
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/notion_to_md/page_property.rb', line 77
def date(prop)
date = prop.dig(:date, :start)
case date
when Date
date.to_time
when String
Time.parse(date)
else
date end
rescue NoMethodError
nil
end
|
.email(prop) ⇒ Object
62
63
64
65
66
|
# File 'lib/notion_to_md/page_property.rb', line 62
def email(prop)
prop[:email]
rescue NoMethodError
nil
end
|
.emoji(prop) ⇒ Object
20
21
22
23
24
|
# File 'lib/notion_to_md/page_property.rb', line 20
def emoji(prop)
prop[:emoji]
rescue NoMethodError
nil
end
|
.external(prop) ⇒ Object
14
15
16
17
18
|
# File 'lib/notion_to_md/page_property.rb', line 14
def external(prop)
prop.dig(:external, :url)
rescue NoMethodError
nil
end
|
.file(prop) ⇒ Object
8
9
10
11
12
|
# File 'lib/notion_to_md/page_property.rb', line 8
def file(prop)
prop.dig(:file, :url)
rescue NoMethodError
nil
end
|
.files(prop) ⇒ Object
44
45
46
47
48
|
# File 'lib/notion_to_md/page_property.rb', line 44
def files(prop)
prop[:files].map { |f| file(f) || external(f) }
rescue NoMethodError
nil
end
|
.multi_select(prop) ⇒ Object
26
27
28
29
30
|
# File 'lib/notion_to_md/page_property.rb', line 26
def multi_select(prop)
prop[:multi_select].map { |sel| sel[:name] }
rescue NoMethodError
nil
end
|
.number(prop) ⇒ Object
56
57
58
59
60
|
# File 'lib/notion_to_md/page_property.rb', line 56
def number(prop)
prop[:number]
rescue NoMethodError
nil
end
|
.people(prop) ⇒ Object
38
39
40
41
42
|
# File 'lib/notion_to_md/page_property.rb', line 38
def people(prop)
prop[:people].map { |sel| sel[:name] }
rescue NoMethodError
nil
end
|
.phone_number(prop) ⇒ Object
50
51
52
53
54
|
# File 'lib/notion_to_md/page_property.rb', line 50
def phone_number(prop)
prop[:phone_number]
rescue NoMethodError
nil
end
|
.rich_text(prop) ⇒ Object
98
99
100
101
102
103
|
# File 'lib/notion_to_md/page_property.rb', line 98
def rich_text(prop)
text = prop[:rich_text].map { |text| text[:plain_text] }.join
text.blank? ? nil : escape_frontmatter_value(text)
rescue NoMethodError
nil
end
|
.select(prop) ⇒ Object
32
33
34
35
36
|
# File 'lib/notion_to_md/page_property.rb', line 32
def select(prop)
escape_frontmatter_value(prop.dig(:select, :name))
rescue NoMethodError
nil
end
|
.url(prop) ⇒ Object
92
93
94
95
96
|
# File 'lib/notion_to_md/page_property.rb', line 92
def url(prop)
prop[:url]
rescue NoMethodError
nil
end
|