Class: NotionRubyMapping::MentionObject

Inherits:
RichTextObject show all
Defined in:
lib/notion_ruby_mapping/mention_object.rb

Overview

TextObject

Instance Attribute Summary

Attributes inherited from RichTextObject

#will_update

Instance Method Summary collapse

Methods inherited from RichTextObject

#bold=, #code=, #color=, create_from_json, #italic=, #plain_text=, #property_values_json, #strikethrough=, text_object, #underline=

Constructor Details

#initialize(options = {}) ⇒ MentionObject



7
8
9
# File 'lib/notion_ruby_mapping/mention_object.rb', line 7

def initialize(options = {})
  super "mention", options
end

Instance Method Details

#partial_property_values_jsonObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/notion_ruby_mapping/mention_object.rb', line 16

def partial_property_values_json
  if @options.key? "user_id"
    {
      "type" => "user",
      "user" => {
        "object" => "user",
        "id" => @options["user_id"],
      },
    }
  elsif @options.key? "page_id"
    {
      "type" => "page",
      "page" => {
        "id" => @options["page_id"],
      },
    }
  elsif @options.key? "database_id"
    {
      "type" => "database",
      "database" => {
        "id" => @options["database_id"],
      },
    }
  elsif @options.key? "start"
    {
      "type" => "date",
      "date" => @options.slice("start", "end", "time_zone"),
    }
  elsif @options.key? "template_mention"
    sub = case @options["template_mention"]
          when "today"
            @options["plain_text"] = "@Today"
            {
              "type" => "template_mention_date",
              "template_mention_date" => "today",
            }
          when "now"
            @options["plain_text"] = "@Now"
            {
              "type" => "template_mention_date",
              "template_mention_date" => "now",
            }
          else
            @options["plain_text"] = "@Me"
            {
              "type" => "template_mention_user",
              "template_mention_user" => "me",
            }
          end
    {
      "type" => "template_mention",
      "template_mention" => sub,
    }
  else
    raise StandardError, "Irregular mention type: #{@options.keys}"
  end
end

#textString (frozen)



12
13
14
# File 'lib/notion_ruby_mapping/mention_object.rb', line 12

def text
  ""
end