Class: NotionRubyMapping::DateProperty
Overview
Constant Summary
collapse
- TYPE =
"date"
Instance Attribute Summary
Attributes inherited from Property
#name, #property_cache, #property_id, #will_update
Instance Method Summary
collapse
date_from_obj, #filter_after, #filter_before, #filter_does_not_equal, #filter_equals, #filter_next_month, #filter_next_week, #filter_next_year, #filter_on_or_after, #filter_on_or_before, #filter_past_month, #filter_past_week, #filter_past_year, start_end_time, value_str, #value_str
#filter_is_empty, #filter_is_not_empty
Methods inherited from Property
#assert_database_property, #assert_page_property, #clear_will_update, #contents?, create_from_json, #database?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type, #update_from_json, #update_property_schema_json
Constructor Details
#initialize(name, will_update: false, base_type: :page, json: nil, start_date: nil, end_date: nil, time_zone: nil, property_cache: nil) ⇒ DateProperty
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 78
def initialize(name, will_update: false, base_type: :page, json: nil, start_date: nil, end_date: nil, time_zone: nil, property_cache: nil)
super name, will_update: will_update, base_type: base_type, property_cache: property_cache
@json = json || {}
return if database?
@json = json || {}
@json["start"] = start_date if start_date
@json["end"] = end_date if end_date
@json["time_zone"] = time_zone if time_zone
end
|
Instance Method Details
#date ⇒ Hash
14
15
16
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 14
def date
@json
end
|
#end_date ⇒ Date, ...
22
23
24
25
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 22
def end_date
assert_page_property __method__
@json["end"]
end
|
#end_date=(edt) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 29
def end_date=(edt)
assert_page_property __method__
@will_update = true
sdt = start_date
edt = nil if sdt.class != edt.class || sdt > edt
@json["end"] = edt
end
|
#property_values_json ⇒ Hash
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 92
def property_values_json
assert_page_property __method__
{
@name => {
"type" => "date",
"date" => {
"start" => value_str(@json["start"]),
"end" => value_str(@json["end"]),
"time_zone" => @json["time_zone"],
},
},
}
end
|
#start_date ⇒ Date, ...
39
40
41
42
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 39
def start_date
assert_page_property __method__
@json["start"]
end
|
#start_date=(sdt) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 46
def start_date=(sdt)
assert_page_property __method__
@will_update = true
edt = end_date
@json["end"] = nil if sdt.class != edt.class || sdt > edt
@json["start"] = sdt
end
|
#time_zone ⇒ String
56
57
58
59
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 56
def time_zone
assert_page_property __method__
@json["time_zone"]
end
|
#time_zone=(tzone) ⇒ Object
63
64
65
66
67
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 63
def time_zone=(tzone)
assert_page_property __method__
@will_update = true
@json["time_zone"] = tzone
end
|