Class: NotionRubyMapping::UrlProperty

Inherits:
Property
  • Object
show all
Includes:
ContainsDoesNotContain, EqualsDoesNotEqual, IsEmptyIsNotEmpty, StartsWithEndsWith
Defined in:
lib/notion_ruby_mapping/url_property.rb

Overview

UrlProperty

Constant Summary collapse

TYPE =
"url"

Instance Attribute Summary

Attributes inherited from Property

#name, #will_update

Instance Method Summary collapse

Methods included from IsEmptyIsNotEmpty

#filter_is_empty, #filter_is_not_empty

Methods included from StartsWithEndsWith

#filter_ends_with, #filter_starts_with

Methods included from ContainsDoesNotContain

#filter_contains, #filter_does_not_contain

Methods included from EqualsDoesNotEqual

#filter_does_not_equal, #filter_equals

Methods inherited from Property

#assert_database_property, #assert_page_property, #clear_will_update, create_from_json, #database?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #type, #update_from_json, #update_property_schema_json

Constructor Details

#initialize(name, will_update: false, base_type: :page, json: nil) ⇒ UrlProperty

Returns a new instance of UrlProperty.

Parameters:

  • name (String)

    Property name

  • url (String)

    url value (optional)



34
35
36
37
# File 'lib/notion_ruby_mapping/url_property.rb', line 34

def initialize(name, will_update: false, base_type: :page, json: nil)
  super name, will_update: will_update, base_type: base_type
  @json = json || (database? ? {} : nil)
end

Instance Method Details

#property_values_jsonHash

Returns:

  • (Hash)


42
43
44
45
# File 'lib/notion_ruby_mapping/url_property.rb', line 42

def property_values_json
  assert_page_property __method__
  {@name => {"url" => @json, "type" => "url"}}
end

#urlString, ...

Returns url (Page), {} (Database).

Returns:

  • (String, Hash, nil)

    url (Page), {} (Database)



17
18
19
# File 'lib/notion_ruby_mapping/url_property.rb', line 17

def url
  @json
end

#url=(url) ⇒ Object

Page property only methods



23
24
25
26
# File 'lib/notion_ruby_mapping/url_property.rb', line 23

def url=(url)
  @will_update = true
  @json = url
end