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 ⇒ Hash
-
#end_date ⇒ Date, ...
-
#end_date=(edt) ⇒ Object
-
#end_date_obj ⇒ Object
-
#initialize(name, will_update: false, base_type: "page", json: nil, start_date: nil, end_date: nil, time_zone: nil, property_id: nil, property_cache: nil) ⇒ DateProperty
constructor
A new instance of DateProperty.
-
#property_values_json ⇒ Hash
-
#start_date ⇒ Date, ...
-
#start_date=(sdt) ⇒ Object
-
#start_date_obj ⇒ Object
-
#time_zone ⇒ String
-
#time_zone=(tzone) ⇒ Object
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, #filter_this_week, 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_id: nil, property_cache: nil) ⇒ DateProperty
Returns a new instance of DateProperty.
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 100
def initialize(name, will_update: false, base_type: "page", json: nil, start_date: nil, end_date: nil,
time_zone: nil, property_id: nil, property_cache: nil)
super name, will_update: will_update, base_type: base_type, property_id: property_id,
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
40
41
42
43
44
45
46
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 40
def end_date=(edt)
assert_page_property __method__
@will_update = true
@json["end"] = edt
end
|
#end_date_obj ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 27
def end_date_obj
assert_page_property __method__
jet = @json["end"]
case jet
when String
jet.include?("T") ? Time.parse(jet) : Date.parse(jet)
else
jet
end
end
|
#property_values_json ⇒ Hash
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 116
def property_values_json
assert_page_property __method__
{
@name => {
"type" => TYPE,
"date" => {
"start" => value_str(@json["start"]),
"end" => value_str(@json["end"]),
"time_zone" => @json["time_zone"],
},
},
}
end
|
#start_date ⇒ Date, ...
50
51
52
53
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 50
def start_date
assert_page_property __method__
@json["start"]
end
|
#start_date=(sdt) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 68
def start_date=(sdt)
assert_page_property __method__
@will_update = true
@json["start"] = sdt
end
|
#start_date_obj ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 55
def start_date_obj
assert_page_property __method__
jst = @json["start"]
case jst
when String
jst.include?("T") ? Time.parse(jst) : Date.parse(jst)
else
jst
end
end
|
#time_zone ⇒ String
78
79
80
81
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 78
def time_zone
assert_page_property __method__
@json[:time_zone]
end
|
#time_zone=(tzone) ⇒ Object
85
86
87
88
89
|
# File 'lib/notion_ruby_mapping/properties/date_property.rb', line 85
def time_zone=(tzone)
assert_page_property __method__
@will_update = true
@json[:time_zone] = tzone
end
|